This project was developed by Xavier Hernan in the MBD April intake in 2022 as a Computer Vision individual assignment. The initial data and task was taken from PIKTOR dataset available from the following github:
https://github.com/ciber-lab/pictor-ppe#dataset
This notebook includes all the steps of the process of building an object detection pipeline: Training, validation, test, based on YOLOv8.
Before importing data from Roboflow, I performed several steps. I uploaded images to a project called 'xavi-assignment' and added three .txt files containing annotations for the images, categorizing them into Hat (0), Vest (1), and Worker (2). Some images were manually annotated as they were not previously labeled. Then, I added an augmentation technique of horizontal flip to my model. The images were divided into 76% training, 14% validation, and 10% test sets using a train-test split. All the images were flipped horizontally and vertically, and cropped with 0% Minimum Zoom and 20% Maximum Zoom.
Finally, I exported the dataset in the appropiate format for each case.
YOLOv8
The following link provides a comprehensive overview of the YOLOv8 model, including various resources to comprehend its workings and usage.
Link: https://blog.roboflow.com/how-to-train-yolov8-on-a-custom-dataset/
The following link features a step-by-step video tutorial on building a YOLOv8 model, based on the notebook mentioned in the article.
Link: https://www.youtube.com/watch?v=wuZtUMEiKWY&feature=youtu.be
YOLOv5
The following link provides a comprehensive overview of the YOLOv5 model, including various resources to comprehend its workings and usage. Navegating withinh the website is it possible to reack code and clarifications.
Link: https://roboflow.com/model/yolov5
Roboflow and Ultralytics libraries are intalled in here. Also I check the status of the installed software and its dependencies.
!pip install roboflow
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting roboflow
Downloading roboflow-0.2.29-py3-none-any.whl (49 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.0/49.0 KB 2.7 MB/s eta 0:00:00
Requirement already satisfied: idna==2.10 in /usr/local/lib/python3.8/dist-packages (from roboflow) (2.10)
Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.8/dist-packages (from roboflow) (1.4.4)
Collecting requests-toolbelt
Downloading requests_toolbelt-0.10.1-py2.py3-none-any.whl (54 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 54.5/54.5 KB 4.4 MB/s eta 0:00:00
Collecting urllib3>=1.26.6
Downloading urllib3-1.26.14-py2.py3-none-any.whl (140 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 140.6/140.6 KB 8.3 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.18.5 in /usr/local/lib/python3.8/dist-packages (from roboflow) (1.21.6)
Requirement already satisfied: tqdm>=4.41.0 in /usr/local/lib/python3.8/dist-packages (from roboflow) (4.64.1)
Collecting wget
Downloading wget-3.2.zip (10 kB)
Preparing metadata (setup.py) ... done
Collecting python-dotenv
Downloading python_dotenv-0.21.1-py3-none-any.whl (19 kB)
Collecting cycler==0.10.0
Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Requirement already satisfied: Pillow>=7.1.2 in /usr/local/lib/python3.8/dist-packages (from roboflow) (7.1.2)
Requirement already satisfied: certifi==2022.12.7 in /usr/local/lib/python3.8/dist-packages (from roboflow) (2022.12.7)
Requirement already satisfied: chardet==4.0.0 in /usr/local/lib/python3.8/dist-packages (from roboflow) (4.0.0)
Collecting pyparsing==2.4.7
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.8/67.8 KB 4.0 MB/s eta 0:00:00
Requirement already satisfied: python-dateutil in /usr/local/lib/python3.8/dist-packages (from roboflow) (2.8.2)
Requirement already satisfied: PyYAML>=5.3.1 in /usr/local/lib/python3.8/dist-packages (from roboflow) (6.0)
Requirement already satisfied: six in /usr/local/lib/python3.8/dist-packages (from roboflow) (1.15.0)
Requirement already satisfied: matplotlib in /usr/local/lib/python3.8/dist-packages (from roboflow) (3.2.2)
Requirement already satisfied: requests in /usr/local/lib/python3.8/dist-packages (from roboflow) (2.25.1)
Requirement already satisfied: opencv-python>=4.1.2 in /usr/local/lib/python3.8/dist-packages (from roboflow) (4.6.0.66)
Building wheels for collected packages: wget
Building wheel for wget (setup.py) ... done
Created wheel for wget: filename=wget-3.2-py3-none-any.whl size=9674 sha256=7717a9741afd9c60a06a112533c4e8886e02afc02dba95aa8ce1f46036dd5e84
Stored in directory: /root/.cache/pip/wheels/bd/a8/c3/3cf2c14a1837a4e04bd98631724e81f33f462d86a1d895fae0
Successfully built wget
Installing collected packages: wget, urllib3, python-dotenv, pyparsing, cycler, requests-toolbelt, roboflow
Attempting uninstall: urllib3
Found existing installation: urllib3 1.24.3
Uninstalling urllib3-1.24.3:
Successfully uninstalled urllib3-1.24.3
Attempting uninstall: pyparsing
Found existing installation: pyparsing 3.0.9
Uninstalling pyparsing-3.0.9:
Successfully uninstalled pyparsing-3.0.9
Attempting uninstall: cycler
Found existing installation: cycler 0.11.0
Uninstalling cycler-0.11.0:
Successfully uninstalled cycler-0.11.0
Successfully installed cycler-0.10.0 pyparsing-2.4.7 python-dotenv-0.21.1 requests-toolbelt-0.10.1 roboflow-0.2.29 urllib3-1.26.14 wget-3.2
!pip install ultralytics==8.0.11
#Check the status of the installed software and its dependencies
import ultralytics
ultralytics.checks()
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) Setup complete ✅ (2 CPUs, 12.7 GB RAM, 23.6/78.2 GB disk)
#Import pandas
import pandas as pd
#Import numpy
import numpy as np
# Import derivates ultralytics
from ultralytics import YOLO
from IPython.display import display, Image
# Import matplotlib
import matplotlib.pyplot as plt
#Import Roboflow
from roboflow import Roboflow
#Import os
import os
#Import glob
import glob
#Functions from the IPython
from IPython.display import Image, display
Running !nvidia-smi to display the current status of the NVIDIA GPUs in the system, including the GPU utilization, temperature, memory usage, and power consumption.
!nvidia-smi
Fri Feb 3 18:38:33 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 Off | 00000000:00:04.0 Off | 0 |
| N/A 48C P0 28W / 70W | 3MiB / 15360MiB | 5% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
import os
HOME = os.getcwd()
print(HOME)
/content
This code has been taken from the export site of roboflow. The first line %cd {HOME} sets the current working directory to the home directory. Same code will be used for following models to be trained.
After this, it creates an instance of it with the API key AeQawE2luCK6NpaA9hPL and it retrieves the project xavi-assignment from the workspace computer-vision-f69jp and the dataset version 2 from that project. Finally, it downloads the dataset with the label format "yolov8".
!mkdir {HOME}/datasets
%cd {HOME}/datasets
rf = Roboflow(api_key="AeQawE2luCK6NpaA9hPL")
project = rf.workspace("computer-vision-f69jp").project("xavi-assignment")
dataset = project.version(2).download("yolov8")
/content/datasets loading Roboflow workspace... loading Roboflow project... Downloading Dataset Version Zip in xavi-assignment-2 to yolov8: 100% [167357377 / 167357377] bytes
Extracting Dataset Version Zip to xavi-assignment-2 in yolov8:: 100%|██████████| 3564/3564 [00:01<00:00, 2300.32it/s]
Here I am running a shell command yolo with various parameters to training an Object detection Model based on YOLOv8.
The hyperparameters selected are:
I would have also loved to try models with more parameters but because of the computational cost it have and the limited time I had to avoid doing so. My next steps would have been applying learning rate to ensures that my model updates its weights effectively. I also could have tryied with the batch size for a faster convergence. Also, a different optimizer type to update the model's weights so it could have improved performance. Finally, another thing that I would have liked to do is changing number of hidden layers to improve the model's ability to learn complex relationships, but I didn't do that because finding the optimal one is not an easy task, as it takes long time of try and error (because using too many layers could result in overfitting).
%cd {HOME}
!yolo task=detect mode=train model=yolov8s.pt data={dataset.location}/data.yaml epochs=30 imgsz=750 dropout=0.5 nms=0.5 plots=True
/content Downloading https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8s.pt to yolov8s.pt... 100% 21.5M/21.5M [00:02<00:00, 10.8MB/s] Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) yolo/engine/trainer: task=detect, mode=train, model=yolov8s.pt, data=/content/datasets/xavi-assignment-2/data.yaml, epochs=30, patience=50, batch=16, imgsz=750, save=True, cache=False, device=, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=False, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, overlap_mask=True, mask_ratio=4, dropout=0.5, val=True, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, hide_labels=False, hide_conf=False, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, retina_masks=False, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=17, workspace=4, nms=0.5, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, fl_gamma=0.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, hydra={'output_subdir': None, 'run': {'dir': '.'}}, v5loader=False, save_dir=runs/detect/train Downloading https://ultralytics.com/assets/Arial.ttf to /root/.config/Ultralytics/Arial.ttf... 100% 755k/755k [00:00<00:00, 29.7MB/s] Overriding model.yaml nc=80 with nc=3 from n params module arguments 0 -1 1 928 ultralytics.nn.modules.Conv [3, 32, 3, 2] 1 -1 1 18560 ultralytics.nn.modules.Conv [32, 64, 3, 2] 2 -1 1 29056 ultralytics.nn.modules.C2f [64, 64, 1, True] 3 -1 1 73984 ultralytics.nn.modules.Conv [64, 128, 3, 2] 4 -1 2 197632 ultralytics.nn.modules.C2f [128, 128, 2, True] 5 -1 1 295424 ultralytics.nn.modules.Conv [128, 256, 3, 2] 6 -1 2 788480 ultralytics.nn.modules.C2f [256, 256, 2, True] 7 -1 1 1180672 ultralytics.nn.modules.Conv [256, 512, 3, 2] 8 -1 1 1838080 ultralytics.nn.modules.C2f [512, 512, 1, True] 9 -1 1 656896 ultralytics.nn.modules.SPPF [512, 512, 5] 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 11 [-1, 6] 1 0 ultralytics.nn.modules.Concat [1] 12 -1 1 591360 ultralytics.nn.modules.C2f [768, 256, 1] 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 14 [-1, 4] 1 0 ultralytics.nn.modules.Concat [1] 15 -1 1 148224 ultralytics.nn.modules.C2f [384, 128, 1] 16 -1 1 147712 ultralytics.nn.modules.Conv [128, 128, 3, 2] 17 [-1, 12] 1 0 ultralytics.nn.modules.Concat [1] 18 -1 1 493056 ultralytics.nn.modules.C2f [384, 256, 1] 19 -1 1 590336 ultralytics.nn.modules.Conv [256, 256, 3, 2] 20 [-1, 9] 1 0 ultralytics.nn.modules.Concat [1] 21 -1 1 1969152 ultralytics.nn.modules.C2f [768, 512, 1] 22 [15, 18, 21] 1 2117209 ultralytics.nn.modules.Detect [3, [128, 256, 512]] Model summary: 225 layers, 11136761 parameters, 11136745 gradients, 28.7 GFLOPs Transferred 349/355 items from pretrained weights WARNING ⚠️ --img-size [750] must be multiple of max stride 32, updating to [768] optimizer: SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 64 weight(decay=0.0005), 63 bias train: Scanning /content/datasets/xavi-assignment-2/train/labels... 1503 images, 1 backgrounds, 0 corrupt: 100% 1503/1503 [00:01<00:00, 1491.22it/s] train: New cache created: /content/datasets/xavi-assignment-2/train/labels.cache albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) val: Scanning /content/datasets/xavi-assignment-2/valid/labels... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<00:00, 1141.98it/s] val: New cache created: /content/datasets/xavi-assignment-2/valid/labels.cache Image sizes 768 train, 768 val Using 2 dataloader workers Logging results to runs/detect/train Starting training for 30 epochs... Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 1/30 8.1G 1.267 1.747 1.268 81 768: 100% 94/94 [01:22<00:00, 1.15it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.12it/s] all 157 811 0.85 0.415 0.454 0.309 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 2/30 9.96G 1.166 1.086 1.168 134 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.54it/s] all 157 811 0.853 0.416 0.486 0.305 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 3/30 9.96G 1.184 1.093 1.169 91 768: 100% 94/94 [01:14<00:00, 1.27it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.49it/s] all 157 811 0.77 0.386 0.414 0.254 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 4/30 9.96G 1.243 1.134 1.195 108 768: 100% 94/94 [01:13<00:00, 1.27it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.55it/s] all 157 811 0.759 0.406 0.413 0.25 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 5/30 9.96G 1.262 1.13 1.195 94 768: 100% 94/94 [01:14<00:00, 1.27it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.35it/s] all 157 811 0.816 0.402 0.427 0.243 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 6/30 9.96G 1.275 1.119 1.203 142 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.44it/s] all 157 811 0.415 0.625 0.562 0.328 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 7/30 9.96G 1.238 1.057 1.19 191 768: 100% 94/94 [01:13<00:00, 1.27it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.52it/s] all 157 811 0.85 0.381 0.487 0.274 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 8/30 9.96G 1.205 1.02 1.185 92 768: 100% 94/94 [01:15<00:00, 1.25it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.50it/s] all 157 811 0.523 0.579 0.608 0.32 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 9/30 9.96G 1.219 1.028 1.173 120 768: 100% 94/94 [01:13<00:00, 1.27it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.52it/s] all 157 811 0.87 0.399 0.562 0.324 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 10/30 9.96G 1.177 0.962 1.147 109 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.53it/s] all 157 811 0.859 0.409 0.46 0.269 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 11/30 9.96G 1.158 0.9254 1.15 82 768: 100% 94/94 [01:14<00:00, 1.26it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.47it/s] all 157 811 0.87 0.428 0.568 0.319 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 12/30 9.96G 1.117 0.8834 1.128 125 768: 100% 94/94 [01:13<00:00, 1.29it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.53it/s] all 157 811 0.875 0.424 0.59 0.339 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 13/30 9.96G 1.101 0.873 1.115 77 768: 100% 94/94 [01:14<00:00, 1.26it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.49it/s] all 157 811 0.533 0.768 0.579 0.335 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 14/30 9.96G 1.085 0.8607 1.103 128 768: 100% 94/94 [01:12<00:00, 1.29it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.45it/s] all 157 811 0.658 0.518 0.601 0.339 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 15/30 9.96G 1.065 0.8236 1.105 73 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.35it/s] all 157 811 0.879 0.427 0.512 0.304 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 16/30 9.96G 1.033 0.7766 1.076 107 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.55it/s] all 157 811 0.522 0.66 0.719 0.392 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 17/30 9.96G 1.014 0.7484 1.067 81 768: 100% 94/94 [01:12<00:00, 1.29it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.53it/s] all 157 811 0.64 0.652 0.656 0.38 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 18/30 9.96G 0.9875 0.7246 1.062 137 768: 100% 94/94 [01:14<00:00, 1.26it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.54it/s] all 157 811 0.514 0.656 0.553 0.335 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 19/30 9.96G 0.9724 0.727 1.053 98 768: 100% 94/94 [01:12<00:00, 1.30it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.53it/s] all 157 811 0.633 0.648 0.637 0.401 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 20/30 9.96G 0.9633 0.6854 1.039 139 768: 100% 94/94 [01:13<00:00, 1.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.54it/s] all 157 811 0.811 0.697 0.788 0.41 Closing dataloader mosaic albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 21/30 9.96G 0.9344 0.6335 1.019 98 768: 100% 94/94 [00:41<00:00, 2.28it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.43it/s] all 157 811 0.726 0.59 0.632 0.425 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 22/30 9.96G 0.912 0.6056 1.005 67 768: 100% 94/94 [00:39<00:00, 2.37it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.52it/s] all 157 811 0.625 0.647 0.664 0.401 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 23/30 9.96G 0.8916 0.5871 0.9977 63 768: 100% 94/94 [00:39<00:00, 2.39it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.55it/s] all 157 811 0.657 0.649 0.663 0.392 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 24/30 9.96G 0.8731 0.5721 0.9839 66 768: 100% 94/94 [00:39<00:00, 2.36it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.53it/s] all 157 811 0.77 0.79 0.8 0.433 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 25/30 9.96G 0.8509 0.5493 0.9721 73 768: 100% 94/94 [00:39<00:00, 2.36it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.50it/s] all 157 811 0.709 0.568 0.646 0.368 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 26/30 9.96G 0.8377 0.5318 0.9696 74 768: 100% 94/94 [00:40<00:00, 2.34it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.34it/s] all 157 811 0.666 0.656 0.718 0.412 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 27/30 9.96G 0.8058 0.5094 0.9581 61 768: 100% 94/94 [00:39<00:00, 2.37it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.48it/s] all 157 811 0.721 0.809 0.771 0.469 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 28/30 9.96G 0.7859 0.5015 0.9557 64 768: 100% 94/94 [00:39<00:00, 2.37it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.57it/s] all 157 811 0.782 0.648 0.676 0.428 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 29/30 9.96G 0.7751 0.4828 0.9465 77 768: 100% 94/94 [00:39<00:00, 2.37it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:03<00:00, 1.48it/s] all 157 811 0.684 0.559 0.628 0.374 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 30/30 9.96G 0.7468 0.466 0.9346 63 768: 100% 94/94 [00:39<00:00, 2.38it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.08s/it] all 157 811 0.642 0.646 0.628 0.383 30 epochs completed in 0.558 hours. Optimizer stripped from runs/detect/train/weights/last.pt, 22.6MB Optimizer stripped from runs/detect/train/weights/best.pt, 22.6MB Validating runs/detect/train/weights/best.pt... Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) Fusing... Model summary: 168 layers, 11126745 parameters, 0 gradients, 28.4 GFLOPs Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.20s/it] all 157 811 0.721 0.808 0.772 0.48 0 157 317 0.758 0.666 0.676 0.426 1 157 4 0.658 0.968 0.828 0.463 2 157 490 0.747 0.79 0.811 0.551 Speed: 5.9ms pre-process, 7.0ms inference, 0.0ms loss, 2.2ms post-process per image Saving runs/detect/train/predictions.json... Results saved to runs/detect/train
Here I am plotting four different graphs for showing the optput of the Object Detection model. These are: F1 curve, Precision curve, Precision&Recall curve, and Recall curve.
fig, axs = plt.subplots(2, 2, figsize=(20, 20))
axs[0, 0].imshow(plt.imread('./runs/detect/train/F1_curve.png'))
axs[0, 1].imshow(plt.imread('./runs/detect/train/P_curve.png'))
axs[1, 0].imshow(plt.imread('./runs/detect/train/PR_curve.png'))
axs[1, 1].imshow(plt.imread('./runs/detect/train/R_curve.png'))
plt.show()
Then I plotted the confusion matrix of the model to see how well the model is performing in terms of accuracy and identifying the correct classes or categories.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train/confusion_matrix.png'))
plt.axis('off')
plt.show()
Finally, the key metrics monitored by YOLOv8 were also displayed here.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train/results.png'))
plt.axis('off')
plt.show()
This is the validation mode on a pre-trained model. The chosen validation mode indicates that the algorithm will be evaluated on a validation set and the performance metrics will be reported, rather than making predictions on new data.
%cd {HOME}
!yolo task=detect mode=val model={HOME}/runs/detect/train/weights/best.pt data={dataset.location}/data.yaml
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 168 layers, 11126745 parameters, 0 gradients, 28.4 GFLOPs
val: Scanning /content/datasets/xavi-assignment-2/valid/labels.cache... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<?, ?it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100% 10/10 [00:05<00:00, 1.85it/s]
all 157 811 0.67 0.629 0.644 0.368
0 157 317 0.776 0.628 0.65 0.407
1 157 4 0.464 0.5 0.484 0.154
2 157 490 0.772 0.758 0.799 0.542
Speed: 3.6ms pre-process, 10.5ms inference, 0.0ms loss, 2.3ms post-process per image
The code runs the prediction mode on a pre-trained model. The algorithm is tasked with detecting objects in a set of images, with a confidence threshold of 0'25.
%cd {HOME}
!yolo task=detect mode=predict model={HOME}/runs/detect/train/weights/best.pt conf=0.25 source={dataset.location}/test/images save=True
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 168 layers, 11126745 parameters, 0 gradients, 28.4 GFLOPs
image 1/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1006-_jpg.rf.fcffc35f7df46be0dbfbeddb60da2f37.jpg: 640x640 5 0s, 6 2s, 17.1ms
image 2/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1015-_jpg.rf.b908086696208f5cb853fd9b5fe27a6e.jpg: 640x640 4 0s, 7 2s, 17.2ms
image 3/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1067-_jpg.rf.0137ad485cbe02a2605d5ec05bce81df.jpg: 640x640 1 0, 1 2, 17.1ms
image 4/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1088-_jpg.rf.f6c4e2dbc1c35d59b86fe8967ce2f195.jpg: 640x640 1 0, 4 2s, 17.1ms
image 5/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1127-_jpg.rf.4641a82acaafceee8bd7f318ec6aa8b1.jpg: 640x640 1 0, 3 2s, 17.1ms
image 6/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1133-_jpg.rf.9207e30152eb405ec982124438f626f5.jpg: 640x640 1 0, 1 2, 17.2ms
image 7/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1167-_jpg.rf.5070b95b4404237515b570affa51f583.jpg: 640x640 1 2, 17.1ms
image 8/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1168-1-_jpg.rf.22faca96d161f76cedadb98d701ce583.jpg: 640x640 1 2, 17.2ms
image 9/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1253-_jpg.rf.d4682a68f5763cdb52916ece44dd4828.jpg: 640x640 3 0s, 8 2s, 17.1ms
image 10/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1295-_jpg.rf.7f116cb966d0c2f4c1be56ba58ee671b.jpg: 640x640 1 2, 17.1ms
image 11/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1296-_jpg.rf.75f9115b510bdcdffb14641e277ccba4.jpg: 640x640 2 0s, 3 2s, 15.8ms
image 12/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-13-_jpg.rf.7a40e69b3e1c09658105ef710ae0826d.jpg: 640x640 1 2, 15.7ms
image 13/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1321-_jpg.rf.12597bf391179239f46403aa2d9b9a9a.jpg: 640x640 1 0, 2 2s, 17.4ms
image 14/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1340-_jpg.rf.e02855b43e16dac33307501ac77bf48a.jpg: 640x640 2 2s, 15.8ms
image 15/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1379-_jpg.rf.7c99d9f22e29303e7d5bdfb1a70c9532.jpg: 640x640 4 2s, 15.8ms
image 16/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1389-_jpg.rf.f1cd8f41f82f0e8179060c3f5db213c0.jpg: 640x640 4 0s, 5 2s, 15.4ms
image 17/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1395-_jpg.rf.ef249a50b280ad5d030370fdc2408142.jpg: 640x640 2 0s, 1 2, 15.4ms
image 18/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1415-_jpg.rf.f5ed437947c24201a8a4f44bc0ad959e.jpg: 640x640 3 0s, 4 2s, 15.5ms
image 19/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1416-_jpg.rf.baaef7d80c94781f3f1f8934c10a0127.jpg: 640x640 3 0s, 6 2s, 15.4ms
image 20/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1426-_jpg.rf.110a561e2e43c8ed1df8e856e85de010.jpg: 640x640 2 2s, 15.4ms
image 21/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1430-_jpg.rf.09aa85ab6365bcb0605cf3b0c10759c3.jpg: 640x640 1 0, 8 2s, 15.5ms
image 22/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1533-_jpg.rf.246f155e7e8df4d454f28d4df80bbef5.jpg: 640x640 2 2s, 15.5ms
image 23/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1600-_jpg.rf.90b634187e71aa17f2f70cb854e08b53.jpg: 640x640 3 0s, 8 2s, 15.4ms
image 24/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1656-_jpg.rf.db021a1dcee28f63dcf41d8fdede94ad.jpg: 640x640 4 2s, 15.5ms
image 25/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1682-_jpg.rf.9c6723e15f13beebee73ac6204c001df.jpg: 640x640 1 0, 3 2s, 15.5ms
image 26/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1723-_jpg.rf.6685b5751c8cdd22d1667e44a73a19b2.jpg: 640x640 1 0, 3 2s, 15.5ms
image 27/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1750-_jpg.rf.0923bb83dc226c3e240c13fff7d2dbd0.jpg: 640x640 1 2, 15.6ms
image 28/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1784-_jpg.rf.f28c856c43a6f61cd19f0cf97631c240.jpg: 640x640 3 2s, 15.4ms
image 29/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1810-_jpg.rf.870b52ed1a1dc7e6cf667f4c8ab666c1.jpg: 640x640 1 0, 1 2, 15.6ms
image 30/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1851-_jpg.rf.c832e8a2ab32ff4fe4263cea253e4138.jpg: 640x640 1 2, 15.5ms
image 31/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1852-_jpg.rf.54ced5a083d90e5da4be087facf4b1aa.jpg: 640x640 1 2, 15.2ms
image 32/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1881-_jpg.rf.580a0c44abf1fcbc62db5c561a0002ce.jpg: 640x640 1 0, 3 2s, 14.2ms
image 33/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1882-1-_jpg.rf.3077e4e65235deae87b49819532be160.jpg: 640x640 3 0s, 5 2s, 14.2ms
image 34/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1900-_jpg.rf.d1794fec7b204a55555d817fac5e8e11.jpg: 640x640 2 0s, 3 2s, 14.2ms
image 35/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1966-_jpg.rf.7a1fe4524f872a830fa0f95ac3a3f7d8.jpg: 640x640 6 0s, 11 2s, 14.1ms
image 36/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1992-_jpg.rf.fffe9b7b55952ae3d443f3a273064bd3.jpg: 640x640 1 2, 14.2ms
image 37/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2-_jpg.rf.6eec08d43c47f64c9ca78b000fa42dfa.jpg: 640x640 4 0s, 4 2s, 14.1ms
image 38/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2070-_jpg.rf.b9d7465913077085ebfe4a80251b7de2.jpg: 640x640 1 2, 14.1ms
image 39/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2074-_jpg.rf.d8141447d731e30e1be05445ada39c6b.jpg: 640x640 6 0s, 15 2s, 14.2ms
image 40/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2135-_jpg.rf.e1abc9cfa073c6b03ffef112bee801e8.jpg: 640x640 1 2, 14.1ms
image 41/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2181-_jpg.rf.a4f4d35a44dbf22578128422be93667c.jpg: 640x640 3 2s, 14.1ms
image 42/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2187-_jpg.rf.9f3280abff1fa620b4554eadf2aafdbe.jpg: 640x640 2 0s, 2 2s, 14.1ms
image 43/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2194-_jpg.rf.f3e33d572c45910e7459b56adc0d284c.jpg: 640x640 2 2s, 14.1ms
image 44/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2215-_jpg.rf.c22a696e5408d5641eaab0764634daed.jpg: 640x640 3 2s, 14.1ms
image 45/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2248-_jpg.rf.abd19b7897ea7ca3e236d89dfc393fca.jpg: 640x640 1 2, 14.2ms
image 46/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-236-_jpg.rf.7cd6a2178c6d2fca3b2acca880ba82f0.jpg: 640x640 1 0, 2 2s, 14.1ms
image 47/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2375-_jpg.rf.05ed09db1f9b15a2c5a891046cff3d12.jpg: 640x640 8 2s, 14.1ms
image 48/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-239-_jpg.rf.eb2d756e47603865a4a4e6aa28b34cca.jpg: 640x640 1 0, 3 2s, 13.3ms
image 49/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2470-_jpg.rf.2839f5cee00558b64bcc76324c9f6d93.jpg: 640x640 2 0s, 4 2s, 13.3ms
image 50/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2566-_jpg.rf.7ede3f2c7861e12bf1ae411eaec3f174.jpg: 640x640 9 2s, 13.3ms
image 51/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2625-_jpg.rf.b2fc4099ec835b41b05b666cb63665ea.jpg: 640x640 1 0, 1 2, 13.2ms
image 52/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2665-_jpg.rf.1fc2a536eb98d3fac22d30fe1d3063bc.jpg: 640x640 2 0s, 4 2s, 13.3ms
image 53/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-267-_jpg.rf.5cc13828cf197606d5dc440bdca22a00.jpg: 640x640 1 2, 13.3ms
image 54/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2699-_jpg.rf.44008fda1a4ad66db9d556873ecdb657.jpg: 640x640 1 0, 2 2s, 13.3ms
image 55/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2702-_jpg.rf.b82fd4e2ec2cfa4bc26651359701a80d.jpg: 640x640 1 0, 2 2s, 13.3ms
image 56/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2705-_jpg.rf.352291096bacd8107fa2784859470389.jpg: 640x640 2 0s, 4 2s, 13.3ms
image 57/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2739-_jpg.rf.4ef1e246b65d6ad06d81f45d17dae9af.jpg: 640x640 1 0, 2 2s, 13.3ms
image 58/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2741-_jpg.rf.ec7693b1da3d215b371adb47957b3599.jpg: 640x640 1 0, 2 2s, 13.2ms
image 59/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2757-_jpg.rf.a7ffbc45fb6086122fd312ec63838fb7.jpg: 640x640 1 0, 2 1s, 4 2s, 13.3ms
image 60/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2826-1-_jpg.rf.5bcef3a8d8331d65ac17c905f11e390c.jpg: 640x640 4 0s, 5 2s, 13.3ms
image 61/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2844-_jpg.rf.d44d6826c9f2e5accbf96abcef2dae52.jpg: 640x640 1 0, 6 2s, 13.2ms
image 62/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2845-_jpg.rf.45c8c9e5ee54a402813c5fdc79968386.jpg: 640x640 1 0, 1 2, 13.3ms
image 63/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2869-_jpg.rf.133760bb6a054ec496b2ec19af049a53.jpg: 640x640 7 2s, 13.3ms
image 64/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-289-_jpg.rf.2d5ff008d776144f0827bed0a8723093.jpg: 640x640 1 0, 2 2s, 13.3ms
image 65/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3092-_jpg.rf.5c2fb24278a53c172170d767b31c81e2.jpg: 640x640 1 0, 1 2, 13.3ms
image 66/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-314-_jpg.rf.6c413bee95858967ad2dc3058b2aa73b.jpg: 640x640 1 2, 13.3ms
image 67/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-315-_jpg.rf.da03dea6974f80eeed598f58cbe7040e.jpg: 640x640 1 2, 13.3ms
image 68/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3187-_jpg.rf.ac02dc6457bb2eae0c7fb8f63729e453.jpg: 640x640 7 2s, 13.3ms
image 69/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3277-_jpg.rf.0663b24eeecc6112e4af3b78f98265b6.jpg: 640x640 4 2s, 13.4ms
image 70/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3280-_jpg.rf.037927121fd603eac3a183c037f6d4fb.jpg: 640x640 4 2s, 13.3ms
image 71/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3283-_jpg.rf.9412b8089be384ecde7f6f8c28ea6308.jpg: 640x640 2 2s, 13.0ms
image 72/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3284-_jpg.rf.d2d3f76e155872389976506469620d91.jpg: 640x640 4 2s, 13.1ms
image 73/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-341-_jpg.rf.f62a50916a5f403289e7997ae78cbd7e.jpg: 640x640 2 0s, 8 2s, 13.0ms
image 74/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3647-_jpg.rf.32c6e3364f7169461c491e24d046202e.jpg: 640x640 1 0, 1 2, 13.1ms
image 75/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-370-_jpg.rf.d3a543161306981edcdace41f7f25e8f.jpg: 640x640 2 0s, 3 2s, 13.0ms
image 76/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3949-_jpg.rf.7099bd81480f56fc2346740f5fd85d3e.jpg: 640x640 1 2, 13.1ms
image 77/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4005-_jpg.rf.ca7eb0807def03a7d4d6190eb648f3b3.jpg: 640x640 2 2s, 13.1ms
image 78/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4182-_jpg.rf.9960c353050b2099e48e4e0605b3ea9f.jpg: 640x640 7 0s, 12 2s, 13.1ms
image 79/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4197-_jpg.rf.96ce536443a206bc55941a8f608b94bf.jpg: 640x640 4 0s, 2 2s, 13.1ms
image 80/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4198-_jpg.rf.b25c94ceecafb6c7d917db9636beae51.jpg: 640x640 1 0, 2 2s, 13.1ms
image 81/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4209-_jpg.rf.3488ca7a5b40781d2988758c734531d5.jpg: 640x640 2 0s, 1 2, 13.1ms
image 82/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4216-_jpg.rf.63a002c30068775e51b71dcff94e06cd.jpg: 640x640 2 0s, 2 2s, 13.1ms
image 83/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4235-_jpg.rf.28853402ededbf01cd941595fe196e93.jpg: 640x640 4 0s, 2 1s, 5 2s, 13.1ms
image 84/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4297-_jpg.rf.cdf57603a691dc34f4af618c0eb1b745.jpg: 640x640 2 0s, 9 2s, 13.0ms
image 85/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4300-_jpg.rf.c11f41cbc1445944683058e3afc882ba.jpg: 640x640 3 0s, 4 2s, 13.1ms
image 86/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4307-_jpg.rf.3997767077f3f3357b5d6be900e220ca.jpg: 640x640 3 0s, 3 2s, 13.1ms
image 87/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4314-_jpg.rf.4f632a08488cdecd5951a01b3a9d27c5.jpg: 640x640 1 0, 1 2, 13.1ms
image 88/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4319-_jpg.rf.675f9aad2a10ec3cc5966769feebe30b.jpg: 640x640 1 0, 1 2, 13.1ms
image 89/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4375-_jpg.rf.b45dcff87a9934ccb30319649780f702.jpg: 640x640 6 0s, 2 1s, 8 2s, 13.1ms
image 90/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4425-_jpg.rf.744cd900f3ea0addb0603078aaa0dca2.jpg: 640x640 8 0s, 7 2s, 13.1ms
image 91/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4453-_jpg.rf.2f0f7c06254b5c0238febfefc4778f89.jpg: 640x640 1 0, 2 2s, 13.0ms
image 92/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4458-_jpg.rf.732066ae5beb1744517f988e9d6366fc.jpg: 640x640 2 0s, 2 2s, 13.1ms
image 93/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4461-_jpg.rf.9fcf6607edbf161fb399ca11a3344fe8.jpg: 640x640 1 0, 2 2s, 13.1ms
image 94/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4482-_jpg.rf.b248d0e961cbaa016fca3d914f3556f2.jpg: 640x640 1 0, 1 2, 13.1ms
image 95/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4490-_jpg.rf.98843547c9f843d5c49a39c44a64860e.jpg: 640x640 2 2s, 13.1ms
image 96/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4497-_jpg.rf.35569d8fb1eb103066c10dee5be25a32.jpg: 640x640 1 0, 1 2, 13.1ms
image 97/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-486-_jpg.rf.d5e0ca24f0bd0eb498b2d9a0e3a243a0.jpg: 640x640 2 0s, 2 2s, 13.1ms
image 98/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-487-_jpg.rf.ddfe445fccb84291b520ef0d8aa79037.jpg: 640x640 1 0, 2 2s, 13.1ms
image 99/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-629-_jpg.rf.6e9085bd517b5bb4522a70b4d0a44e77.jpg: 640x640 5 0s, 4 2s, 12.9ms
image 100/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-674-_jpg.rf.54acbedf14c5233e7e9de14d9f3a0b1a.jpg: 640x640 5 0s, 11 2s, 12.9ms
image 101/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-688-_jpg.rf.1f8e4088f3dc382d92321fb8e0099052.jpg: 640x640 7 0s, 12 2s, 12.9ms
image 102/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-689-_jpg.rf.78f30433dda124f0389ac5f21ba9d232.jpg: 640x640 9 0s, 19 2s, 12.9ms
image 103/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-693-_jpg.rf.4e77574ef0da13c3b0f8457ba3374e4c.jpg: 640x640 10 0s, 9 2s, 12.9ms
image 104/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-710-_jpg.rf.2592a5747f008c6c21d77c8d99fa5ca2.jpg: 640x640 1 0, 4 2s, 12.9ms
image 105/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-713-_jpg.rf.fbc9931de0a298d4f27e2470f4a89525.jpg: 640x640 6 0s, 9 2s, 12.9ms
image 106/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-720-_jpg.rf.9c8db287066e19b56b2dd809b04a380c.jpg: 640x640 2 0s, 3 2s, 12.9ms
image 107/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-721-_jpg.rf.9ad085984359c2c08bfff93972b5fc5c.jpg: 640x640 1 0, 2 2s, 12.9ms
image 108/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-736-_jpg.rf.65cab46d95e25948ff402ed47ce674f5.jpg: 640x640 6 0s, 13 2s, 12.9ms
image 109/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-775-_jpg.rf.45f87606efaffea474f4d99912e5f7b4.jpg: 640x640 1 0, 2 2s, 12.9ms
image 110/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-778-_jpg.rf.568c0281f600cc2bbf9deee8cfda866a.jpg: 640x640 4 0s, 7 2s, 13.0ms
image 111/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-795-_jpg.rf.de3a6aef54016b3a4616a14d1e08ea38.jpg: 640x640 8 0s, 20 2s, 12.9ms
image 112/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-835-_jpg.rf.09cdcac00b8c95c20097f5123becd4e9.jpg: 640x640 6 0s, 7 2s, 12.9ms
image 113/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-858-_jpg.rf.f4c1b37165763eea66c37e71ab8c8f40.jpg: 640x640 12.9ms
image 114/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-892-_jpg.rf.4e30fa08ea48048365a8cfc69c11b338.jpg: 640x640 1 0, 1 2, 12.9ms
image 115/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-946-_jpg.rf.82fe49cf646c495659d030549dcac09e.jpg: 640x640 1 0, 3 2s, 12.9ms
image 116/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-960-_jpg.rf.624206fd8d069d806666409b83ec14b4.jpg: 640x640 2 2s, 12.8ms
Speed: 0.5ms pre-process, 14.0ms inference, 1.5ms postprocess per image at shape (1, 3, 640, 640)
Results saved to runs/detect/predict
I am plotting some outputs to evaluate the model's performance and view examples.
image_paths = glob.glob(f'/content/runs/detect/predict/*.jpg')[:3]
for image_path in image_paths:
image = plt.imread(image_path)
plt.figure(figsize=(10,10))
plt.imshow(image)
plt.axis('off')
plt.show()
To make a fair comparison while experimenting with different neural networks, I will use now 'yolov8m.pt' model for comparing it with the previuos one and see how the performance have changed.
It creates an instance of it with the API key AeQawE2luCK6NpaA9hPL and it retrieves the project xavi-assignment from the workspace computer-vision-f69jp and the dataset version 2 from that project. Finally, it downloads the dataset with the label format "yolov8".
!mkdir {HOME}/datasets
%cd {HOME}/datasets
rf = Roboflow(api_key="AeQawE2luCK6NpaA9hPL")
project = rf.workspace("computer-vision-f69jp").project("xavi-assignment")
dataset = project.version(2).download("yolov8")
mkdir: cannot create directory ‘/content/datasets’: File exists /content/datasets loading Roboflow workspace... loading Roboflow project... Downloading Dataset Version Zip in xavi-assignment-2 to yolov8: 100% [167357377 / 167357377] bytes
Extracting Dataset Version Zip to xavi-assignment-2 in yolov8:: 100%|██████████| 3564/3564 [00:02<00:00, 1579.46it/s]
Here I am running the same shell command yolo as before tunning the model to the medium one. All others remain the same. I did that in order to compare both models in the same conditions.
The hyperparameters selected are:
I would have also loved to try models with more parameters but because of the computational cost it have and the limited time I had to avoid doing so. My next steps would have been applying learning rate to ensures that my model updates its weights effectively. I also could have tryied with the batch size for a faster convergence. Also, a different optimizer type to update the model's weights so it could have improved performance. Finally, another thing that I would have liked to do is changing number of hidden layers to improve the model's ability to learn complex relationships, but I didn't do that because finding the optimal one is not an easy task, as it takes long time of try and error (because using too many layers could result in overfitting).
%cd {HOME}
!yolo task=detect mode=train model=yolov8m.pt data={dataset.location}/data.yaml epochs=30 imgsz=750 dropout=0.5 nms=0.5 plots=True
/content Downloading https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8m.pt to yolov8m.pt... 100% 49.7M/49.7M [00:01<00:00, 28.4MB/s] Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) yolo/engine/trainer: task=detect, mode=train, model=yolov8m.pt, data=/content/datasets/xavi-assignment-2/data.yaml, epochs=30, patience=50, batch=16, imgsz=750, save=True, cache=False, device=, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=False, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, overlap_mask=True, mask_ratio=4, dropout=0.5, val=True, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, hide_labels=False, hide_conf=False, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, retina_masks=False, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=17, workspace=4, nms=0.5, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, fl_gamma=0.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, hydra={'output_subdir': None, 'run': {'dir': '.'}}, v5loader=False, save_dir=runs/detect/train2 Overriding model.yaml nc=80 with nc=3 from n params module arguments 0 -1 1 1392 ultralytics.nn.modules.Conv [3, 48, 3, 2] 1 -1 1 41664 ultralytics.nn.modules.Conv [48, 96, 3, 2] 2 -1 2 111360 ultralytics.nn.modules.C2f [96, 96, 2, True] 3 -1 1 166272 ultralytics.nn.modules.Conv [96, 192, 3, 2] 4 -1 4 813312 ultralytics.nn.modules.C2f [192, 192, 4, True] 5 -1 1 664320 ultralytics.nn.modules.Conv [192, 384, 3, 2] 6 -1 4 3248640 ultralytics.nn.modules.C2f [384, 384, 4, True] 7 -1 1 1991808 ultralytics.nn.modules.Conv [384, 576, 3, 2] 8 -1 2 3985920 ultralytics.nn.modules.C2f [576, 576, 2, True] 9 -1 1 831168 ultralytics.nn.modules.SPPF [576, 576, 5] 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 11 [-1, 6] 1 0 ultralytics.nn.modules.Concat [1] 12 -1 2 1993728 ultralytics.nn.modules.C2f [960, 384, 2] 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 14 [-1, 4] 1 0 ultralytics.nn.modules.Concat [1] 15 -1 2 517632 ultralytics.nn.modules.C2f [576, 192, 2] 16 -1 1 332160 ultralytics.nn.modules.Conv [192, 192, 3, 2] 17 [-1, 12] 1 0 ultralytics.nn.modules.Concat [1] 18 -1 2 1846272 ultralytics.nn.modules.C2f [576, 384, 2] 19 -1 1 1327872 ultralytics.nn.modules.Conv [384, 384, 3, 2] 20 [-1, 9] 1 0 ultralytics.nn.modules.Concat [1] 21 -1 2 4207104 ultralytics.nn.modules.C2f [960, 576, 2] 22 [15, 18, 21] 1 3777433 ultralytics.nn.modules.Detect [3, [192, 384, 576]] Model summary: 295 layers, 25858057 parameters, 25858041 gradients, 79.1 GFLOPs Transferred 469/475 items from pretrained weights WARNING ⚠️ --img-size [750] must be multiple of max stride 32, updating to [768] optimizer: SGD(lr=0.01) with parameter groups 77 weight(decay=0.0), 84 weight(decay=0.0005), 83 bias train: Scanning /content/datasets/xavi-assignment-2/train/labels.cache... 1503 images, 1 backgrounds, 0 corrupt: 100% 1503/1503 [00:00<?, ?it/s] albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) val: Scanning /content/datasets/xavi-assignment-2/valid/labels.cache... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<?, ?it/s] Image sizes 768 train, 768 val Using 2 dataloader workers Logging results to runs/detect/train2 Starting training for 30 epochs... Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 1/30 11.6G 1.202 1.914 1.263 81 768: 100% 94/94 [01:29<00:00, 1.05it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.05it/s] all 157 811 0.857 0.43 0.465 0.328 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 2/30 13.5G 1.064 0.9843 1.135 134 768: 100% 94/94 [01:28<00:00, 1.06it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.894 0.425 0.483 0.326 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 3/30 13.5G 1.102 0.977 1.152 91 768: 100% 94/94 [01:26<00:00, 1.09it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.849 0.397 0.463 0.284 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 4/30 13.5G 1.175 1.069 1.2 108 768: 100% 94/94 [01:28<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.788 0.386 0.518 0.259 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 5/30 13.5G 1.215 1.084 1.216 94 768: 100% 94/94 [01:26<00:00, 1.09it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.843 0.388 0.446 0.264 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 6/30 13.5G 1.202 1.066 1.194 142 768: 100% 94/94 [01:26<00:00, 1.09it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.574 0.495 0.542 0.294 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 7/30 13.5G 1.17 0.9915 1.18 191 768: 100% 94/94 [01:28<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.85 0.419 0.53 0.305 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 8/30 13.5G 1.131 0.939 1.183 92 768: 100% 94/94 [01:26<00:00, 1.09it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.839 0.421 0.562 0.299 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 9/30 13.5G 1.141 0.9382 1.172 120 768: 100% 94/94 [01:28<00:00, 1.06it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.09it/s] all 157 811 0.839 0.406 0.461 0.28 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 10/30 13.5G 1.106 0.8996 1.144 109 768: 100% 94/94 [01:27<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.864 0.438 0.512 0.304 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 11/30 13.5G 1.091 0.8593 1.148 82 768: 100% 94/94 [01:28<00:00, 1.06it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.851 0.431 0.562 0.324 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 12/30 13.5G 1.047 0.8112 1.121 125 768: 100% 94/94 [01:27<00:00, 1.08it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.10it/s] all 157 811 0.701 0.606 0.605 0.355 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 13/30 13.5G 1.035 0.7977 1.115 77 768: 100% 94/94 [01:28<00:00, 1.06it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.789 0.611 0.71 0.411 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 14/30 13.5G 1.02 0.7852 1.103 128 768: 100% 94/94 [01:27<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.715 0.585 0.667 0.348 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 15/30 13.5G 0.9833 0.7448 1.094 73 768: 100% 94/94 [01:28<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.638 0.663 0.704 0.386 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 16/30 13.5G 0.9611 0.7046 1.072 107 768: 100% 94/94 [01:28<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.564 0.569 0.585 0.359 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 17/30 13.5G 0.9419 0.6868 1.059 81 768: 100% 94/94 [01:27<00:00, 1.08it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.728 0.59 0.665 0.384 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 18/30 13.5G 0.9116 0.6663 1.055 137 768: 100% 94/94 [01:28<00:00, 1.06it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.771 0.688 0.743 0.413 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 19/30 13.5G 0.8948 0.6604 1.053 98 768: 100% 94/94 [01:26<00:00, 1.08it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.886 0.698 0.752 0.387 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 20/30 13.5G 0.8866 0.6175 1.032 139 768: 100% 94/94 [01:28<00:00, 1.07it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.875 0.62 0.727 0.401 Closing dataloader mosaic albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 21/30 13.5G 0.8536 0.5554 1.004 98 768: 100% 94/94 [01:18<00:00, 1.19it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.677 0.718 0.671 0.4 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 22/30 13.5G 0.8346 0.5354 0.9896 67 768: 100% 94/94 [01:17<00:00, 1.21it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.718 0.547 0.606 0.371 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 23/30 13.5G 0.8098 0.5108 0.9866 63 768: 100% 94/94 [01:17<00:00, 1.21it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.721 0.659 0.692 0.414 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 24/30 13.5G 0.7841 0.4974 0.9683 66 768: 100% 94/94 [01:17<00:00, 1.22it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.06it/s] all 157 811 0.709 0.541 0.631 0.381 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 25/30 13.5G 0.7641 0.4703 0.9556 73 768: 100% 94/94 [01:17<00:00, 1.21it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.727 0.522 0.617 0.382 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 26/30 13.5G 0.7427 0.4614 0.9543 74 768: 100% 94/94 [01:17<00:00, 1.22it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.699 0.558 0.65 0.401 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 27/30 13.5G 0.7194 0.4335 0.9384 61 768: 100% 94/94 [01:17<00:00, 1.22it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.862 0.607 0.729 0.399 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 28/30 13.5G 0.7156 0.4306 0.9407 64 768: 100% 94/94 [01:17<00:00, 1.22it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.07it/s] all 157 811 0.755 0.651 0.662 0.408 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 29/30 13.5G 0.6858 0.4108 0.9277 77 768: 100% 94/94 [01:17<00:00, 1.21it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:04<00:00, 1.08it/s] all 157 811 0.92 0.612 0.767 0.408 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 30/30 13.5G 0.6668 0.3964 0.9181 63 768: 100% 94/94 [01:17<00:00, 1.22it/s] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:07<00:00, 1.47s/it] all 157 811 0.922 0.619 0.787 0.423 30 epochs completed in 0.752 hours. Optimizer stripped from runs/detect/train2/weights/last.pt, 52.1MB Optimizer stripped from runs/detect/train2/weights/best.pt, 52.1MB Validating runs/detect/train2/weights/best.pt... Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) Fusing... Model summary: 218 layers, 25841497 parameters, 0 gradients, 78.7 GFLOPs Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:07<00:00, 1.41s/it] all 157 811 0.922 0.619 0.787 0.423 0 157 317 0.918 0.602 0.736 0.474 1 157 4 0.951 0.5 0.781 0.202 2 157 490 0.896 0.755 0.845 0.592 Speed: 5.9ms pre-process, 15.6ms inference, 0.0ms loss, 2.0ms post-process per image Saving runs/detect/train2/predictions.json... Results saved to runs/detect/train2
Here I am plotting four different graphs for showing the optput of the Object Detection model. These are: F1 curve, Precision curve, Precision&Recall curve, and Recall curve.
fig, axs = plt.subplots(2, 2, figsize=(20, 20))
axs[0, 0].imshow(plt.imread('./runs/detect/train2/F1_curve.png'))
axs[0, 1].imshow(plt.imread('./runs/detect/train2/P_curve.png'))
axs[1, 0].imshow(plt.imread('./runs/detect/train2/PR_curve.png'))
axs[1, 1].imshow(plt.imread('./runs/detect/train2/R_curve.png'))
plt.show()
Then I plotted the confusion matrix of the model to see how well the model is performing in terms of accuracy and identifying the correct classes or categories.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train2/confusion_matrix.png'))
plt.axis('off')
plt.show()
Finally, the key metrics monitored by YOLOv8 were also displayed here.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train2/results.png'))
plt.axis('off')
plt.show()
This is the validation mode on a pre-trained model. The chosen validation mode indicates that the algorithm will be evaluated on a validation set and the performance metrics will be reported, rather than making predictions on new data.
%cd {HOME}
!yolo task=detect mode=val model={HOME}/runs/detect/train2/weights/best.pt data={dataset.location}/data.yaml
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 218 layers, 25841497 parameters, 0 gradients, 78.7 GFLOPs
val: Scanning /content/datasets/xavi-assignment-2/valid/labels.cache... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<?, ?it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100% 10/10 [00:07<00:00, 1.38it/s]
all 157 811 0.9 0.595 0.768 0.421
0 157 317 0.902 0.558 0.69 0.447
1 157 4 0.901 0.5 0.781 0.229
2 157 490 0.899 0.727 0.834 0.587
Speed: 2.7ms pre-process, 25.0ms inference, 0.0ms loss, 1.7ms post-process per image
The code runs the prediction mode on a pre-trained model. The algorithm is tasked with detecting objects in a set of images, with a confidence threshold of 0'25.
%cd {HOME}
!yolo task=detect mode=predict model={HOME}/runs/detect/train2/weights/best.pt conf=0.25 source={dataset.location}/test/images save=True
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 218 layers, 25841497 parameters, 0 gradients, 78.7 GFLOPs
image 1/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1006-_jpg.rf.fcffc35f7df46be0dbfbeddb60da2f37.jpg: 640x640 4 0s, 5 2s, 38.1ms
image 2/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1015-_jpg.rf.b908086696208f5cb853fd9b5fe27a6e.jpg: 640x640 4 0s, 5 2s, 35.1ms
image 3/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1067-_jpg.rf.0137ad485cbe02a2605d5ec05bce81df.jpg: 640x640 1 0, 1 2, 35.0ms
image 4/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1088-_jpg.rf.f6c4e2dbc1c35d59b86fe8967ce2f195.jpg: 640x640 2 0s, 1 2, 35.1ms
image 5/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1127-_jpg.rf.4641a82acaafceee8bd7f318ec6aa8b1.jpg: 640x640 1 0, 4 2s, 27.8ms
image 6/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1133-_jpg.rf.9207e30152eb405ec982124438f626f5.jpg: 640x640 1 0, 1 2, 27.7ms
image 7/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1167-_jpg.rf.5070b95b4404237515b570affa51f583.jpg: 640x640 1 2, 27.7ms
image 8/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1168-1-_jpg.rf.22faca96d161f76cedadb98d701ce583.jpg: 640x640 1 2, 27.8ms
image 9/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1253-_jpg.rf.d4682a68f5763cdb52916ece44dd4828.jpg: 640x640 5 0s, 6 2s, 21.7ms
image 10/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1295-_jpg.rf.7f116cb966d0c2f4c1be56ba58ee671b.jpg: 640x640 1 2, 21.7ms
image 11/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1296-_jpg.rf.75f9115b510bdcdffb14641e277ccba4.jpg: 640x640 2 0s, 4 2s, 21.4ms
image 12/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-13-_jpg.rf.7a40e69b3e1c09658105ef710ae0826d.jpg: 640x640 1 2, 21.7ms
image 13/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1321-_jpg.rf.12597bf391179239f46403aa2d9b9a9a.jpg: 640x640 1 0, 2 2s, 21.2ms
image 14/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1340-_jpg.rf.e02855b43e16dac33307501ac77bf48a.jpg: 640x640 18.8ms
image 15/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1379-_jpg.rf.7c99d9f22e29303e7d5bdfb1a70c9532.jpg: 640x640 4 2s, 18.8ms
image 16/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1389-_jpg.rf.f1cd8f41f82f0e8179060c3f5db213c0.jpg: 640x640 5 0s, 6 2s, 18.8ms
image 17/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1395-_jpg.rf.ef249a50b280ad5d030370fdc2408142.jpg: 640x640 1 0, 4 2s, 19.1ms
image 18/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1415-_jpg.rf.f5ed437947c24201a8a4f44bc0ad959e.jpg: 640x640 4 0s, 4 2s, 18.5ms
image 19/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1416-_jpg.rf.baaef7d80c94781f3f1f8934c10a0127.jpg: 640x640 3 0s, 5 2s, 18.4ms
image 20/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1426-_jpg.rf.110a561e2e43c8ed1df8e856e85de010.jpg: 640x640 1 2, 18.5ms
image 21/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1430-_jpg.rf.09aa85ab6365bcb0605cf3b0c10759c3.jpg: 640x640 10 2s, 19.0ms
image 22/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1533-_jpg.rf.246f155e7e8df4d454f28d4df80bbef5.jpg: 640x640 3 2s, 18.8ms
image 23/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1600-_jpg.rf.90b634187e71aa17f2f70cb854e08b53.jpg: 640x640 2 0s, 7 2s, 18.4ms
image 24/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1656-_jpg.rf.db021a1dcee28f63dcf41d8fdede94ad.jpg: 640x640 1 2, 18.4ms
image 25/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1682-_jpg.rf.9c6723e15f13beebee73ac6204c001df.jpg: 640x640 1 0, 3 2s, 18.6ms
image 26/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1723-_jpg.rf.6685b5751c8cdd22d1667e44a73a19b2.jpg: 640x640 1 0, 2 2s, 18.9ms
image 27/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1750-_jpg.rf.0923bb83dc226c3e240c13fff7d2dbd0.jpg: 640x640 1 2, 18.8ms
image 28/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1784-_jpg.rf.f28c856c43a6f61cd19f0cf97631c240.jpg: 640x640 3 2s, 18.8ms
image 29/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1810-_jpg.rf.870b52ed1a1dc7e6cf667f4c8ab666c1.jpg: 640x640 1 0, 1 2, 18.8ms
image 30/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1851-_jpg.rf.c832e8a2ab32ff4fe4263cea253e4138.jpg: 640x640 1 2, 19.0ms
image 31/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1852-_jpg.rf.54ced5a083d90e5da4be087facf4b1aa.jpg: 640x640 1 2, 19.0ms
image 32/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1881-_jpg.rf.580a0c44abf1fcbc62db5c561a0002ce.jpg: 640x640 1 0, 3 2s, 18.8ms
image 33/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1882-1-_jpg.rf.3077e4e65235deae87b49819532be160.jpg: 640x640 2 0s, 5 2s, 18.5ms
image 34/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1900-_jpg.rf.d1794fec7b204a55555d817fac5e8e11.jpg: 640x640 2 0s, 2 2s, 18.4ms
image 35/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1966-_jpg.rf.7a1fe4524f872a830fa0f95ac3a3f7d8.jpg: 640x640 7 0s, 8 2s, 18.5ms
image 36/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1992-_jpg.rf.fffe9b7b55952ae3d443f3a273064bd3.jpg: 640x640 1 2, 18.3ms
image 37/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2-_jpg.rf.6eec08d43c47f64c9ca78b000fa42dfa.jpg: 640x640 4 0s, 4 2s, 18.9ms
image 38/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2070-_jpg.rf.b9d7465913077085ebfe4a80251b7de2.jpg: 640x640 1 0, 1 2, 18.3ms
image 39/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2074-_jpg.rf.d8141447d731e30e1be05445ada39c6b.jpg: 640x640 5 0s, 13 2s, 18.5ms
image 40/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2135-_jpg.rf.e1abc9cfa073c6b03ffef112bee801e8.jpg: 640x640 2 2s, 18.1ms
image 41/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2181-_jpg.rf.a4f4d35a44dbf22578128422be93667c.jpg: 640x640 3 2s, 18.8ms
image 42/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2187-_jpg.rf.9f3280abff1fa620b4554eadf2aafdbe.jpg: 640x640 2 0s, 2 2s, 19.0ms
image 43/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2194-_jpg.rf.f3e33d572c45910e7459b56adc0d284c.jpg: 640x640 1 2, 19.0ms
image 44/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2215-_jpg.rf.c22a696e5408d5641eaab0764634daed.jpg: 640x640 3 2s, 18.7ms
image 45/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2248-_jpg.rf.abd19b7897ea7ca3e236d89dfc393fca.jpg: 640x640 1 2, 18.8ms
image 46/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-236-_jpg.rf.7cd6a2178c6d2fca3b2acca880ba82f0.jpg: 640x640 19.2ms
image 47/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2375-_jpg.rf.05ed09db1f9b15a2c5a891046cff3d12.jpg: 640x640 9 2s, 19.2ms
image 48/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-239-_jpg.rf.eb2d756e47603865a4a4e6aa28b34cca.jpg: 640x640 1 0, 3 2s, 19.0ms
image 49/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2470-_jpg.rf.2839f5cee00558b64bcc76324c9f6d93.jpg: 640x640 1 0, 3 2s, 18.8ms
image 50/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2566-_jpg.rf.7ede3f2c7861e12bf1ae411eaec3f174.jpg: 640x640 10 2s, 18.6ms
image 51/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2625-_jpg.rf.b2fc4099ec835b41b05b666cb63665ea.jpg: 640x640 1 0, 1 2, 18.8ms
image 52/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2665-_jpg.rf.1fc2a536eb98d3fac22d30fe1d3063bc.jpg: 640x640 2 0s, 2 2s, 18.5ms
image 53/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-267-_jpg.rf.5cc13828cf197606d5dc440bdca22a00.jpg: 640x640 1 2, 18.2ms
image 54/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2699-_jpg.rf.44008fda1a4ad66db9d556873ecdb657.jpg: 640x640 4 2s, 18.3ms
image 55/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2702-_jpg.rf.b82fd4e2ec2cfa4bc26651359701a80d.jpg: 640x640 1 0, 1 2, 18.8ms
image 56/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2705-_jpg.rf.352291096bacd8107fa2784859470389.jpg: 640x640 4 0s, 4 2s, 18.9ms
image 57/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2739-_jpg.rf.4ef1e246b65d6ad06d81f45d17dae9af.jpg: 640x640 1 0, 1 2, 18.7ms
image 58/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2741-_jpg.rf.ec7693b1da3d215b371adb47957b3599.jpg: 640x640 2 0s, 2 2s, 18.5ms
image 59/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2757-_jpg.rf.a7ffbc45fb6086122fd312ec63838fb7.jpg: 640x640 1 0, 6 2s, 18.9ms
image 60/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2826-1-_jpg.rf.5bcef3a8d8331d65ac17c905f11e390c.jpg: 640x640 4 0s, 7 2s, 19.1ms
image 61/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2844-_jpg.rf.d44d6826c9f2e5accbf96abcef2dae52.jpg: 640x640 2 0s, 5 2s, 18.4ms
image 62/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2845-_jpg.rf.45c8c9e5ee54a402813c5fdc79968386.jpg: 640x640 1 0, 2 2s, 18.6ms
image 63/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2869-_jpg.rf.133760bb6a054ec496b2ec19af049a53.jpg: 640x640 1 0, 8 2s, 18.7ms
image 64/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-289-_jpg.rf.2d5ff008d776144f0827bed0a8723093.jpg: 640x640 1 0, 2 2s, 18.7ms
image 65/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3092-_jpg.rf.5c2fb24278a53c172170d767b31c81e2.jpg: 640x640 1 0, 2 2s, 18.5ms
image 66/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-314-_jpg.rf.6c413bee95858967ad2dc3058b2aa73b.jpg: 640x640 1 2, 18.4ms
image 67/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-315-_jpg.rf.da03dea6974f80eeed598f58cbe7040e.jpg: 640x640 1 2, 18.3ms
image 68/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3187-_jpg.rf.ac02dc6457bb2eae0c7fb8f63729e453.jpg: 640x640 6 2s, 18.4ms
image 69/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3277-_jpg.rf.0663b24eeecc6112e4af3b78f98265b6.jpg: 640x640 3 2s, 18.7ms
image 70/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3280-_jpg.rf.037927121fd603eac3a183c037f6d4fb.jpg: 640x640 4 2s, 18.6ms
image 71/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3283-_jpg.rf.9412b8089be384ecde7f6f8c28ea6308.jpg: 640x640 2 2s, 18.3ms
image 72/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3284-_jpg.rf.d2d3f76e155872389976506469620d91.jpg: 640x640 4 2s, 18.4ms
image 73/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-341-_jpg.rf.f62a50916a5f403289e7997ae78cbd7e.jpg: 640x640 2 0s, 9 2s, 19.0ms
image 74/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3647-_jpg.rf.32c6e3364f7169461c491e24d046202e.jpg: 640x640 1 0, 1 2, 18.6ms
image 75/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-370-_jpg.rf.d3a543161306981edcdace41f7f25e8f.jpg: 640x640 1 0, 3 2s, 18.2ms
image 76/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3949-_jpg.rf.7099bd81480f56fc2346740f5fd85d3e.jpg: 640x640 1 2, 17.9ms
image 77/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4005-_jpg.rf.ca7eb0807def03a7d4d6190eb648f3b3.jpg: 640x640 2 2s, 19.4ms
image 78/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4182-_jpg.rf.9960c353050b2099e48e4e0605b3ea9f.jpg: 640x640 7 0s, 1 1, 13 2s, 19.3ms
image 79/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4197-_jpg.rf.96ce536443a206bc55941a8f608b94bf.jpg: 640x640 4 0s, 4 2s, 18.4ms
image 80/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4198-_jpg.rf.b25c94ceecafb6c7d917db9636beae51.jpg: 640x640 1 0, 2 2s, 18.5ms
image 81/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4209-_jpg.rf.3488ca7a5b40781d2988758c734531d5.jpg: 640x640 1 0, 1 2, 19.2ms
image 82/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4216-_jpg.rf.63a002c30068775e51b71dcff94e06cd.jpg: 640x640 2 0s, 2 2s, 18.7ms
image 83/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4235-_jpg.rf.28853402ededbf01cd941595fe196e93.jpg: 640x640 4 0s, 2 1s, 5 2s, 18.6ms
image 84/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4297-_jpg.rf.cdf57603a691dc34f4af618c0eb1b745.jpg: 640x640 2 0s, 7 2s, 18.9ms
image 85/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4300-_jpg.rf.c11f41cbc1445944683058e3afc882ba.jpg: 640x640 2 0s, 3 2s, 18.7ms
image 86/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4307-_jpg.rf.3997767077f3f3357b5d6be900e220ca.jpg: 640x640 3 0s, 3 2s, 18.6ms
image 87/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4314-_jpg.rf.4f632a08488cdecd5951a01b3a9d27c5.jpg: 640x640 1 0, 1 2, 18.6ms
image 88/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4319-_jpg.rf.675f9aad2a10ec3cc5966769feebe30b.jpg: 640x640 1 0, 1 2, 18.6ms
image 89/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4375-_jpg.rf.b45dcff87a9934ccb30319649780f702.jpg: 640x640 5 0s, 2 1s, 8 2s, 18.8ms
image 90/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4425-_jpg.rf.744cd900f3ea0addb0603078aaa0dca2.jpg: 640x640 8 0s, 7 2s, 18.8ms
image 91/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4453-_jpg.rf.2f0f7c06254b5c0238febfefc4778f89.jpg: 640x640 1 0, 1 2, 18.0ms
image 92/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4458-_jpg.rf.732066ae5beb1744517f988e9d6366fc.jpg: 640x640 2 0s, 3 2s, 18.2ms
image 93/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4461-_jpg.rf.9fcf6607edbf161fb399ca11a3344fe8.jpg: 640x640 2 0s, 2 2s, 18.9ms
image 94/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4482-_jpg.rf.b248d0e961cbaa016fca3d914f3556f2.jpg: 640x640 1 0, 1 2, 18.5ms
image 95/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4490-_jpg.rf.98843547c9f843d5c49a39c44a64860e.jpg: 640x640 3 2s, 18.8ms
image 96/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4497-_jpg.rf.35569d8fb1eb103066c10dee5be25a32.jpg: 640x640 1 0, 1 2, 19.0ms
image 97/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-486-_jpg.rf.d5e0ca24f0bd0eb498b2d9a0e3a243a0.jpg: 640x640 2 0s, 2 2s, 19.1ms
image 98/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-487-_jpg.rf.ddfe445fccb84291b520ef0d8aa79037.jpg: 640x640 2 0s, 2 2s, 19.1ms
image 99/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-629-_jpg.rf.6e9085bd517b5bb4522a70b4d0a44e77.jpg: 640x640 3 0s, 3 2s, 19.2ms
image 100/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-674-_jpg.rf.54acbedf14c5233e7e9de14d9f3a0b1a.jpg: 640x640 2 0s, 9 2s, 18.1ms
image 101/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-688-_jpg.rf.1f8e4088f3dc382d92321fb8e0099052.jpg: 640x640 6 0s, 14 2s, 18.0ms
image 102/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-689-_jpg.rf.78f30433dda124f0389ac5f21ba9d232.jpg: 640x640 9 0s, 16 2s, 18.2ms
image 103/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-693-_jpg.rf.4e77574ef0da13c3b0f8457ba3374e4c.jpg: 640x640 9 0s, 8 2s, 18.9ms
image 104/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-710-_jpg.rf.2592a5747f008c6c21d77c8d99fa5ca2.jpg: 640x640 1 0, 2 2s, 18.0ms
image 105/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-713-_jpg.rf.fbc9931de0a298d4f27e2470f4a89525.jpg: 640x640 7 0s, 10 2s, 18.1ms
image 106/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-720-_jpg.rf.9c8db287066e19b56b2dd809b04a380c.jpg: 640x640 2 0s, 4 2s, 18.0ms
image 107/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-721-_jpg.rf.9ad085984359c2c08bfff93972b5fc5c.jpg: 640x640 4 0s, 7 2s, 18.7ms
image 108/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-736-_jpg.rf.65cab46d95e25948ff402ed47ce674f5.jpg: 640x640 5 0s, 10 2s, 18.6ms
image 109/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-775-_jpg.rf.45f87606efaffea474f4d99912e5f7b4.jpg: 640x640 2 2s, 17.9ms
image 110/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-778-_jpg.rf.568c0281f600cc2bbf9deee8cfda866a.jpg: 640x640 2 0s, 5 2s, 18.7ms
image 111/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-795-_jpg.rf.de3a6aef54016b3a4616a14d1e08ea38.jpg: 640x640 9 0s, 16 2s, 18.9ms
image 112/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-835-_jpg.rf.09cdcac00b8c95c20097f5123becd4e9.jpg: 640x640 5 0s, 6 2s, 18.9ms
image 113/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-858-_jpg.rf.f4c1b37165763eea66c37e71ab8c8f40.jpg: 640x640 17.9ms
image 114/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-892-_jpg.rf.4e30fa08ea48048365a8cfc69c11b338.jpg: 640x640 1 0, 1 2, 18.9ms
image 115/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-946-_jpg.rf.82fe49cf646c495659d030549dcac09e.jpg: 640x640 1 0, 2 2s, 18.4ms
image 116/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-960-_jpg.rf.624206fd8d069d806666409b83ec14b4.jpg: 640x640 3 0s, 1 2, 18.3ms
Speed: 0.5ms pre-process, 19.7ms inference, 1.5ms postprocess per image at shape (1, 3, 640, 640)
Results saved to runs/detect/predict2
I am plotting some outputs to evaluate the model's performance and view examples.
image_paths = glob.glob(f'/content/runs/detect/predict2/*.jpg')[:3]
for image_path in image_paths:
image = plt.imread(image_path)
plt.figure(figsize=(10,10))
plt.imshow(image)
plt.axis('off')
plt.show()
To make a fair comparison while experimenting with different neural networks, I will use now 'yolov8l.pt' model for comparing it with the previuos one and see how the performance have changed.
It creates an instance of it with the API key AeQawE2luCK6NpaA9hPL and it retrieves the project xavi-assignment from the workspace computer-vision-f69jp and the dataset version 2 from that project. Finally, it downloads the dataset with the label format "yolov8".
!mkdir {HOME}/datasets
%cd {HOME}/datasets
rf = Roboflow(api_key="AeQawE2luCK6NpaA9hPL")
project = rf.workspace("computer-vision-f69jp").project("xavi-assignment")
dataset = project.version(2).download("yolov8")
mkdir: cannot create directory ‘/content/datasets’: File exists /content/datasets loading Roboflow workspace... loading Roboflow project... Downloading Dataset Version Zip in xavi-assignment-2 to yolov8: 100% [167357377 / 167357377] bytes
Extracting Dataset Version Zip to xavi-assignment-2 in yolov8:: 100%|██████████| 3564/3564 [00:02<00:00, 1544.42it/s]
Again, I am running a shell command yolo but now with a third different model, the large one. I will compare at the end the scoring of all of them.
The hyperparameters selected are:
I would have also loved to try models with more parameters but because of the computational cost it have and the limited time I had to avoid doing so. My next steps would have been applying learning rate to ensures that my model updates its weights effectively. I also could have tryied with the batch size for a faster convergence. Also, a different optimizer type to update the model's weights so it could have improved performance. Finally, another thing that I would have liked to do is changing number of hidden layers to improve the model's ability to learn complex relationships, but I didn't do that because finding the optimal one is not an easy task, as it takes long time of try and error (because using too many layers could result in overfitting).
%cd {HOME}
!yolo task=detect mode=train model=yolov8l.pt data={dataset.location}/data.yaml epochs=30 imgsz=750 dropout=0.5 nms=0.5 plots=True
/content Downloading https://github.com/ultralytics/assets/releases/download/v0.0.0/yolov8l.pt to yolov8l.pt... 100% 83.7M/83.7M [00:02<00:00, 39.8MB/s] Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) yolo/engine/trainer: task=detect, mode=train, model=yolov8l.pt, data=/content/datasets/xavi-assignment-2/data.yaml, epochs=30, patience=50, batch=16, imgsz=750, save=True, cache=False, device=, workers=8, project=None, name=None, exist_ok=False, pretrained=False, optimizer=SGD, verbose=False, seed=0, deterministic=True, single_cls=False, image_weights=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, overlap_mask=True, mask_ratio=4, dropout=0.5, val=True, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, hide_labels=False, hide_conf=False, vid_stride=1, line_thickness=3, visualize=False, augment=False, agnostic_nms=False, retina_masks=False, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False, opset=17, workspace=4, nms=0.5, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, fl_gamma=0.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, hydra={'output_subdir': None, 'run': {'dir': '.'}}, v5loader=False, save_dir=runs/detect/train3 Overriding model.yaml nc=80 with nc=3 from n params module arguments 0 -1 1 1856 ultralytics.nn.modules.Conv [3, 64, 3, 2] 1 -1 1 73984 ultralytics.nn.modules.Conv [64, 128, 3, 2] 2 -1 3 279808 ultralytics.nn.modules.C2f [128, 128, 3, True] 3 -1 1 295424 ultralytics.nn.modules.Conv [128, 256, 3, 2] 4 -1 6 2101248 ultralytics.nn.modules.C2f [256, 256, 6, True] 5 -1 1 1180672 ultralytics.nn.modules.Conv [256, 512, 3, 2] 6 -1 6 8396800 ultralytics.nn.modules.C2f [512, 512, 6, True] 7 -1 1 2360320 ultralytics.nn.modules.Conv [512, 512, 3, 2] 8 -1 3 4461568 ultralytics.nn.modules.C2f [512, 512, 3, True] 9 -1 1 656896 ultralytics.nn.modules.SPPF [512, 512, 5] 10 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 11 [-1, 6] 1 0 ultralytics.nn.modules.Concat [1] 12 -1 3 4723712 ultralytics.nn.modules.C2f [1024, 512, 3] 13 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 14 [-1, 4] 1 0 ultralytics.nn.modules.Concat [1] 15 -1 3 1247744 ultralytics.nn.modules.C2f [768, 256, 3] 16 -1 1 590336 ultralytics.nn.modules.Conv [256, 256, 3, 2] 17 [-1, 12] 1 0 ultralytics.nn.modules.Concat [1] 18 -1 3 4592640 ultralytics.nn.modules.C2f [768, 512, 3] 19 -1 1 2360320 ultralytics.nn.modules.Conv [512, 512, 3, 2] 20 [-1, 9] 1 0 ultralytics.nn.modules.Concat [1] 21 -1 3 4723712 ultralytics.nn.modules.C2f [1024, 512, 3] 22 [15, 18, 21] 1 5585113 ultralytics.nn.modules.Detect [3, [256, 512, 512]] Model summary: 365 layers, 43632153 parameters, 43632137 gradients, 165.4 GFLOPs Transferred 589/595 items from pretrained weights WARNING ⚠️ --img-size [750] must be multiple of max stride 32, updating to [768] optimizer: SGD(lr=0.01) with parameter groups 97 weight(decay=0.0), 104 weight(decay=0.0005), 103 bias train: Scanning /content/datasets/xavi-assignment-2/train/labels.cache... 1503 images, 1 backgrounds, 0 corrupt: 100% 1503/1503 [00:00<?, ?it/s] albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) val: Scanning /content/datasets/xavi-assignment-2/valid/labels.cache... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<?, ?it/s] Image sizes 768 train, 768 val Using 2 dataloader workers Logging results to runs/detect/train3 Starting training for 30 epochs... Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 1/30 14.1G 1.13 1.837 1.25 81 768: 100% 94/94 [02:01<00:00, 1.29s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.26s/it] all 157 811 0.881 0.418 0.468 0.331 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 2/30 14.3G 1.018 0.9796 1.144 134 768: 100% 94/94 [01:58<00:00, 1.26s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.874 0.425 0.471 0.319 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 3/30 14.3G 1.092 1.032 1.179 91 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.855 0.37 0.453 0.286 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 4/30 14.3G 1.166 1.073 1.22 108 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.22s/it] all 157 811 0.798 0.37 0.452 0.26 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 5/30 14.3G 1.232 1.107 1.249 94 768: 100% 94/94 [01:58<00:00, 1.26s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.20s/it] all 157 811 0.829 0.361 0.425 0.238 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 6/30 14.3G 1.229 1.095 1.248 142 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.23s/it] all 157 811 0.824 0.399 0.418 0.255 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 7/30 14.3G 1.203 1.052 1.233 191 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.18s/it] all 157 811 0.839 0.4 0.421 0.256 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 8/30 14.3G 1.141 0.9737 1.221 92 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.863 0.407 0.503 0.285 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 9/30 14.3G 1.143 0.9398 1.202 120 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.19s/it] all 157 811 0.515 0.405 0.433 0.255 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 10/30 14.3G 1.125 0.9148 1.186 109 768: 100% 94/94 [01:58<00:00, 1.26s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.19s/it] all 157 811 0.882 0.399 0.458 0.268 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 11/30 14.3G 1.085 0.8673 1.177 82 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.837 0.437 0.465 0.281 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 12/30 14.3G 1.052 0.8257 1.157 125 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.20s/it] all 157 811 0.889 0.427 0.53 0.31 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 13/30 14.3G 1.035 0.8022 1.141 77 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.20s/it] all 157 811 0.668 0.565 0.666 0.357 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 14/30 14.3G 1.019 0.7895 1.127 128 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.37s/it] all 157 811 0.586 0.656 0.604 0.322 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 15/30 14.3G 0.982 0.7513 1.116 73 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.19s/it] all 157 811 0.894 0.435 0.603 0.336 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 16/30 14.3G 0.964 0.7075 1.104 107 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.22s/it] all 157 811 0.594 0.545 0.526 0.321 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 17/30 14.3G 0.9325 0.6813 1.083 81 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.20s/it] all 157 811 0.539 0.453 0.5 0.318 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 18/30 14.3G 0.9198 0.663 1.081 137 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.22s/it] all 157 811 0.554 0.561 0.573 0.336 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 19/30 14.3G 0.8959 0.6493 1.069 98 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.26s/it] all 157 811 0.896 0.461 0.553 0.337 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 20/30 14.3G 0.8813 0.6163 1.044 139 768: 100% 94/94 [01:57<00:00, 1.25s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.20s/it] all 157 811 0.878 0.617 0.664 0.36 Closing dataloader mosaic albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 21/30 14.3G 0.8487 0.5525 1.025 98 768: 100% 94/94 [01:56<00:00, 1.24s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.776 0.66 0.715 0.398 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 22/30 14.3G 0.8203 0.5269 1.005 67 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.22s/it] all 157 811 0.71 0.627 0.69 0.425 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 23/30 14.3G 0.7962 0.5025 1.002 63 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.20s/it] all 157 811 0.852 0.607 0.692 0.394 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 24/30 14.3G 0.7739 0.4878 0.9799 66 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.734 0.65 0.722 0.396 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 25/30 14.3G 0.7479 0.4665 0.9679 73 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.20s/it] all 157 811 0.687 0.726 0.714 0.396 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 26/30 14.3G 0.7297 0.439 0.9627 74 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.20s/it] all 157 811 0.889 0.619 0.696 0.398 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 27/30 14.3G 0.702 0.4178 0.9471 61 768: 100% 94/94 [01:54<00:00, 1.21s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:06<00:00, 1.21s/it] all 157 811 0.858 0.719 0.765 0.424 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 28/30 14.3G 0.6856 0.4109 0.9451 64 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.20s/it] all 157 811 0.87 0.642 0.708 0.414 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 29/30 14.3G 0.6653 0.3956 0.936 77 768: 100% 94/94 [01:54<00:00, 1.22s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:05<00:00, 1.19s/it] all 157 811 0.894 0.632 0.698 0.396 Epoch GPU_mem box_loss cls_loss dfl_loss Instances Size 30/30 14.3G 0.6426 0.3739 0.918 63 768: 100% 94/94 [01:54<00:00, 1.21s/it] Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:07<00:00, 1.58s/it] all 157 811 0.907 0.628 0.695 0.391 30 epochs completed in 1.040 hours. Optimizer stripped from runs/detect/train3/weights/last.pt, 87.7MB Optimizer stripped from runs/detect/train3/weights/best.pt, 87.7MB Validating runs/detect/train3/weights/best.pt... Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) Fusing... Model summary: 268 layers, 43608921 parameters, 0 gradients, 164.8 GFLOPs Class Images Instances Box(P R mAP50 mAP50-95): 100% 5/5 [00:08<00:00, 1.73s/it] all 157 811 0.887 0.628 0.744 0.42 0 157 317 0.867 0.637 0.719 0.482 1 157 4 0.939 0.5 0.685 0.196 2 157 490 0.856 0.747 0.829 0.583 Speed: 4.1ms pre-process, 24.4ms inference, 0.0ms loss, 2.6ms post-process per image Saving runs/detect/train3/predictions.json... Results saved to runs/detect/train3
Here I am plotting four different graphs for showing the optput of the Object Detection model. These are: F1 curve, Precision curve, Precision&Recall curve, and Recall curve.
fig, axs = plt.subplots(2, 2, figsize=(20, 20))
axs[0, 0].imshow(plt.imread('./runs/detect/train3/F1_curve.png'))
axs[0, 1].imshow(plt.imread('./runs/detect/train3/P_curve.png'))
axs[1, 0].imshow(plt.imread('./runs/detect/train3/PR_curve.png'))
axs[1, 1].imshow(plt.imread('./runs/detect/train3/R_curve.png'))
plt.show()
Then I plotted the confusion matrix of the model to see how well the model is performing in terms of accuracy and identifying the correct classes or categories.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train3/confusion_matrix.png'))
plt.axis('off')
plt.show()
Finally, the key metrics monitored by YOLOv8 were also displayed here.
fig = plt.figure(dpi=200)
plt.imshow(plt.imread('./runs/detect/train3/results.png'))
plt.axis('off')
plt.show()
This is the validation mode on a pre-trained model. The chosen validation mode indicates that the algorithm will be evaluated on a validation set and the performance metrics will be reported, rather than making predictions on new data.
%cd {HOME}
!yolo task=detect mode=val model={HOME}/runs/detect/train3/weights/best.pt data={dataset.location}/data.yaml
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 268 layers, 43608921 parameters, 0 gradients, 164.8 GFLOPs
val: Scanning /content/datasets/xavi-assignment-2/valid/labels.cache... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<?, ?it/s]
Class Images Instances Box(P R mAP50 mAP50-95): 100% 10/10 [00:09<00:00, 1.06it/s]
all 157 811 0.858 0.602 0.726 0.424
0 157 317 0.872 0.587 0.685 0.45
1 157 4 0.841 0.5 0.685 0.255
2 157 490 0.861 0.72 0.808 0.565
Speed: 2.4ms pre-process, 39.5ms inference, 0.0ms loss, 2.1ms post-process per image
The code runs the prediction mode on a pre-trained model. The algorithm is tasked with detecting objects in a set of images, with a confidence threshold of 0'25.
%cd {HOME}
!yolo task=detect mode=predict model={HOME}/runs/detect/train3/weights/best.pt conf=0.25 source={dataset.location}/test/images save=True
/content
Ultralytics YOLOv8.0.11 🚀 Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB)
Fusing...
Model summary: 268 layers, 43608921 parameters, 0 gradients, 164.8 GFLOPs
image 1/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1006-_jpg.rf.fcffc35f7df46be0dbfbeddb60da2f37.jpg: 640x640 4 0s, 5 2s, 64.5ms
image 2/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1015-_jpg.rf.b908086696208f5cb853fd9b5fe27a6e.jpg: 640x640 4 0s, 6 2s, 52.1ms
image 3/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1067-_jpg.rf.0137ad485cbe02a2605d5ec05bce81df.jpg: 640x640 1 0, 1 2, 43.8ms
image 4/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1088-_jpg.rf.f6c4e2dbc1c35d59b86fe8967ce2f195.jpg: 640x640 1 0, 1 2, 42.9ms
image 5/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1127-_jpg.rf.4641a82acaafceee8bd7f318ec6aa8b1.jpg: 640x640 1 0, 3 2s, 38.9ms
image 6/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1133-_jpg.rf.9207e30152eb405ec982124438f626f5.jpg: 640x640 1 0, 1 2, 34.9ms
image 7/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1167-_jpg.rf.5070b95b4404237515b570affa51f583.jpg: 640x640 1 2, 36.5ms
image 8/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1168-1-_jpg.rf.22faca96d161f76cedadb98d701ce583.jpg: 640x640 1 2, 36.8ms
image 9/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1253-_jpg.rf.d4682a68f5763cdb52916ece44dd4828.jpg: 640x640 4 0s, 6 2s, 36.2ms
image 10/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1295-_jpg.rf.7f116cb966d0c2f4c1be56ba58ee671b.jpg: 640x640 1 2, 33.6ms
image 11/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1296-_jpg.rf.75f9115b510bdcdffb14641e277ccba4.jpg: 640x640 2 0s, 3 2s, 35.7ms
image 12/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-13-_jpg.rf.7a40e69b3e1c09658105ef710ae0826d.jpg: 640x640 1 2, 35.1ms
image 13/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1321-_jpg.rf.12597bf391179239f46403aa2d9b9a9a.jpg: 640x640 1 0, 2 2s, 35.3ms
image 14/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1340-_jpg.rf.e02855b43e16dac33307501ac77bf48a.jpg: 640x640 34.8ms
image 15/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1379-_jpg.rf.7c99d9f22e29303e7d5bdfb1a70c9532.jpg: 640x640 4 2s, 36.0ms
image 16/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1389-_jpg.rf.f1cd8f41f82f0e8179060c3f5db213c0.jpg: 640x640 3 0s, 5 2s, 36.4ms
image 17/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1395-_jpg.rf.ef249a50b280ad5d030370fdc2408142.jpg: 640x640 1 0, 3 2s, 35.5ms
image 18/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1415-_jpg.rf.f5ed437947c24201a8a4f44bc0ad959e.jpg: 640x640 4 0s, 4 2s, 35.3ms
image 19/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1416-_jpg.rf.baaef7d80c94781f3f1f8934c10a0127.jpg: 640x640 3 0s, 5 2s, 36.0ms
image 20/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1426-_jpg.rf.110a561e2e43c8ed1df8e856e85de010.jpg: 640x640 1 2, 33.2ms
image 21/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1430-_jpg.rf.09aa85ab6365bcb0605cf3b0c10759c3.jpg: 640x640 1 0, 9 2s, 34.0ms
image 22/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1533-_jpg.rf.246f155e7e8df4d454f28d4df80bbef5.jpg: 640x640 2 2s, 34.2ms
image 23/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1600-_jpg.rf.90b634187e71aa17f2f70cb854e08b53.jpg: 640x640 3 0s, 9 2s, 34.2ms
image 24/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1656-_jpg.rf.db021a1dcee28f63dcf41d8fdede94ad.jpg: 640x640 1 0, 1 2, 34.4ms
image 25/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1682-_jpg.rf.9c6723e15f13beebee73ac6204c001df.jpg: 640x640 1 0, 3 2s, 35.9ms
image 26/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1723-_jpg.rf.6685b5751c8cdd22d1667e44a73a19b2.jpg: 640x640 1 0, 2 2s, 35.3ms
image 27/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1750-_jpg.rf.0923bb83dc226c3e240c13fff7d2dbd0.jpg: 640x640 1 2, 34.7ms
image 28/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1784-_jpg.rf.f28c856c43a6f61cd19f0cf97631c240.jpg: 640x640 1 2, 36.0ms
image 29/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1810-_jpg.rf.870b52ed1a1dc7e6cf667f4c8ab666c1.jpg: 640x640 1 0, 1 2, 36.4ms
image 30/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1851-_jpg.rf.c832e8a2ab32ff4fe4263cea253e4138.jpg: 640x640 1 2, 35.1ms
image 31/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1852-_jpg.rf.54ced5a083d90e5da4be087facf4b1aa.jpg: 640x640 1 2, 35.2ms
image 32/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1881-_jpg.rf.580a0c44abf1fcbc62db5c561a0002ce.jpg: 640x640 1 0, 3 2s, 35.6ms
image 33/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1882-1-_jpg.rf.3077e4e65235deae87b49819532be160.jpg: 640x640 2 0s, 4 2s, 33.4ms
image 34/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1900-_jpg.rf.d1794fec7b204a55555d817fac5e8e11.jpg: 640x640 2 0s, 2 2s, 34.8ms
image 35/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1966-_jpg.rf.7a1fe4524f872a830fa0f95ac3a3f7d8.jpg: 640x640 6 0s, 9 2s, 35.4ms
image 36/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-1992-_jpg.rf.fffe9b7b55952ae3d443f3a273064bd3.jpg: 640x640 1 2, 33.9ms
image 37/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2-_jpg.rf.6eec08d43c47f64c9ca78b000fa42dfa.jpg: 640x640 5 0s, 4 2s, 36.1ms
image 38/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2070-_jpg.rf.b9d7465913077085ebfe4a80251b7de2.jpg: 640x640 1 2, 36.4ms
image 39/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2074-_jpg.rf.d8141447d731e30e1be05445ada39c6b.jpg: 640x640 5 0s, 12 2s, 37.0ms
image 40/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2135-_jpg.rf.e1abc9cfa073c6b03ffef112bee801e8.jpg: 640x640 2 2s, 33.0ms
image 41/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2181-_jpg.rf.a4f4d35a44dbf22578128422be93667c.jpg: 640x640 1 0, 3 2s, 36.2ms
image 42/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2187-_jpg.rf.9f3280abff1fa620b4554eadf2aafdbe.jpg: 640x640 2 0s, 2 2s, 35.8ms
image 43/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2194-_jpg.rf.f3e33d572c45910e7459b56adc0d284c.jpg: 640x640 2 2s, 35.4ms
image 44/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2215-_jpg.rf.c22a696e5408d5641eaab0764634daed.jpg: 640x640 1 0, 4 2s, 35.3ms
image 45/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2248-_jpg.rf.abd19b7897ea7ca3e236d89dfc393fca.jpg: 640x640 1 2, 35.1ms
image 46/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-236-_jpg.rf.7cd6a2178c6d2fca3b2acca880ba82f0.jpg: 640x640 35.9ms
image 47/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2375-_jpg.rf.05ed09db1f9b15a2c5a891046cff3d12.jpg: 640x640 10 2s, 36.8ms
image 48/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-239-_jpg.rf.eb2d756e47603865a4a4e6aa28b34cca.jpg: 640x640 1 0, 3 2s, 35.6ms
image 49/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2470-_jpg.rf.2839f5cee00558b64bcc76324c9f6d93.jpg: 640x640 1 0, 3 2s, 34.5ms
image 50/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2566-_jpg.rf.7ede3f2c7861e12bf1ae411eaec3f174.jpg: 640x640 9 2s, 35.7ms
image 51/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2625-_jpg.rf.b2fc4099ec835b41b05b666cb63665ea.jpg: 640x640 1 0, 1 2, 35.8ms
image 52/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2665-_jpg.rf.1fc2a536eb98d3fac22d30fe1d3063bc.jpg: 640x640 2 0s, 2 2s, 34.7ms
image 53/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-267-_jpg.rf.5cc13828cf197606d5dc440bdca22a00.jpg: 640x640 2 2s, 36.0ms
image 54/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2699-_jpg.rf.44008fda1a4ad66db9d556873ecdb657.jpg: 640x640 2 2s, 36.4ms
image 55/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2702-_jpg.rf.b82fd4e2ec2cfa4bc26651359701a80d.jpg: 640x640 1 0, 1 2, 36.4ms
image 56/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2705-_jpg.rf.352291096bacd8107fa2784859470389.jpg: 640x640 3 0s, 6 2s, 35.8ms
image 57/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2739-_jpg.rf.4ef1e246b65d6ad06d81f45d17dae9af.jpg: 640x640 1 0, 1 2, 35.1ms
image 58/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2741-_jpg.rf.ec7693b1da3d215b371adb47957b3599.jpg: 640x640 1 0, 2 2s, 36.1ms
image 59/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2757-_jpg.rf.a7ffbc45fb6086122fd312ec63838fb7.jpg: 640x640 1 0, 4 2s, 36.4ms
image 60/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2826-1-_jpg.rf.5bcef3a8d8331d65ac17c905f11e390c.jpg: 640x640 4 0s, 6 2s, 35.8ms
image 61/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2844-_jpg.rf.d44d6826c9f2e5accbf96abcef2dae52.jpg: 640x640 2 0s, 5 2s, 36.1ms
image 62/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2845-_jpg.rf.45c8c9e5ee54a402813c5fdc79968386.jpg: 640x640 1 0, 1 2, 35.8ms
image 63/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-2869-_jpg.rf.133760bb6a054ec496b2ec19af049a53.jpg: 640x640 7 2s, 36.3ms
image 64/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-289-_jpg.rf.2d5ff008d776144f0827bed0a8723093.jpg: 640x640 1 0, 2 2s, 35.4ms
image 65/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3092-_jpg.rf.5c2fb24278a53c172170d767b31c81e2.jpg: 640x640 1 0, 3 2s, 34.3ms
image 66/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-314-_jpg.rf.6c413bee95858967ad2dc3058b2aa73b.jpg: 640x640 1 2, 35.6ms
image 67/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-315-_jpg.rf.da03dea6974f80eeed598f58cbe7040e.jpg: 640x640 1 2, 35.8ms
image 68/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3187-_jpg.rf.ac02dc6457bb2eae0c7fb8f63729e453.jpg: 640x640 5 2s, 36.2ms
image 69/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3277-_jpg.rf.0663b24eeecc6112e4af3b78f98265b6.jpg: 640x640 3 2s, 35.2ms
image 70/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3280-_jpg.rf.037927121fd603eac3a183c037f6d4fb.jpg: 640x640 4 2s, 36.2ms
image 71/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3283-_jpg.rf.9412b8089be384ecde7f6f8c28ea6308.jpg: 640x640 3 2s, 35.4ms
image 72/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3284-_jpg.rf.d2d3f76e155872389976506469620d91.jpg: 640x640 4 2s, 36.8ms
image 73/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-341-_jpg.rf.f62a50916a5f403289e7997ae78cbd7e.jpg: 640x640 2 0s, 7 2s, 35.3ms
image 74/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3647-_jpg.rf.32c6e3364f7169461c491e24d046202e.jpg: 640x640 1 0, 2 2s, 35.3ms
image 75/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-370-_jpg.rf.d3a543161306981edcdace41f7f25e8f.jpg: 640x640 1 0, 3 2s, 36.3ms
image 76/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-3949-_jpg.rf.7099bd81480f56fc2346740f5fd85d3e.jpg: 640x640 1 2, 35.7ms
image 77/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4005-_jpg.rf.ca7eb0807def03a7d4d6190eb648f3b3.jpg: 640x640 3 2s, 36.8ms
image 78/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4182-_jpg.rf.9960c353050b2099e48e4e0605b3ea9f.jpg: 640x640 7 0s, 11 2s, 36.5ms
image 79/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4197-_jpg.rf.96ce536443a206bc55941a8f608b94bf.jpg: 640x640 2 0s, 2 2s, 33.7ms
image 80/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4198-_jpg.rf.b25c94ceecafb6c7d917db9636beae51.jpg: 640x640 1 0, 35.8ms
image 81/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4209-_jpg.rf.3488ca7a5b40781d2988758c734531d5.jpg: 640x640 1 0, 1 2, 35.8ms
image 82/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4216-_jpg.rf.63a002c30068775e51b71dcff94e06cd.jpg: 640x640 2 0s, 2 2s, 31.8ms
image 83/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4235-_jpg.rf.28853402ededbf01cd941595fe196e93.jpg: 640x640 4 0s, 3 1s, 5 2s, 36.2ms
image 84/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4297-_jpg.rf.cdf57603a691dc34f4af618c0eb1b745.jpg: 640x640 2 0s, 7 2s, 36.4ms
image 85/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4300-_jpg.rf.c11f41cbc1445944683058e3afc882ba.jpg: 640x640 2 0s, 3 2s, 36.1ms
image 86/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4307-_jpg.rf.3997767077f3f3357b5d6be900e220ca.jpg: 640x640 3 0s, 3 2s, 36.4ms
image 87/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4314-_jpg.rf.4f632a08488cdecd5951a01b3a9d27c5.jpg: 640x640 1 0, 1 2, 35.1ms
image 88/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4319-_jpg.rf.675f9aad2a10ec3cc5966769feebe30b.jpg: 640x640 1 0, 1 2, 34.8ms
image 89/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4375-_jpg.rf.b45dcff87a9934ccb30319649780f702.jpg: 640x640 6 0s, 8 2s, 34.7ms
image 90/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4425-_jpg.rf.744cd900f3ea0addb0603078aaa0dca2.jpg: 640x640 8 0s, 7 2s, 35.4ms
image 91/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4453-_jpg.rf.2f0f7c06254b5c0238febfefc4778f89.jpg: 640x640 1 0, 1 2, 33.5ms
image 92/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4458-_jpg.rf.732066ae5beb1744517f988e9d6366fc.jpg: 640x640 2 0s, 2 2s, 36.5ms
image 93/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4461-_jpg.rf.9fcf6607edbf161fb399ca11a3344fe8.jpg: 640x640 2 0s, 2 2s, 36.0ms
image 94/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4482-_jpg.rf.b248d0e961cbaa016fca3d914f3556f2.jpg: 640x640 1 0, 1 2, 33.1ms
image 95/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4490-_jpg.rf.98843547c9f843d5c49a39c44a64860e.jpg: 640x640 1 2, 35.5ms
image 96/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-4497-_jpg.rf.35569d8fb1eb103066c10dee5be25a32.jpg: 640x640 1 0, 1 2, 36.8ms
image 97/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-486-_jpg.rf.d5e0ca24f0bd0eb498b2d9a0e3a243a0.jpg: 640x640 2 0s, 2 2s, 36.8ms
image 98/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-487-_jpg.rf.ddfe445fccb84291b520ef0d8aa79037.jpg: 640x640 2 0s, 2 2s, 36.9ms
image 99/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-629-_jpg.rf.6e9085bd517b5bb4522a70b4d0a44e77.jpg: 640x640 5 0s, 4 2s, 35.3ms
image 100/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-674-_jpg.rf.54acbedf14c5233e7e9de14d9f3a0b1a.jpg: 640x640 2 0s, 7 2s, 35.9ms
image 101/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-688-_jpg.rf.1f8e4088f3dc382d92321fb8e0099052.jpg: 640x640 7 0s, 12 2s, 36.0ms
image 102/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-689-_jpg.rf.78f30433dda124f0389ac5f21ba9d232.jpg: 640x640 8 0s, 18 2s, 34.1ms
image 103/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-693-_jpg.rf.4e77574ef0da13c3b0f8457ba3374e4c.jpg: 640x640 9 0s, 8 2s, 33.3ms
image 104/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-710-_jpg.rf.2592a5747f008c6c21d77c8d99fa5ca2.jpg: 640x640 2 0s, 3 2s, 34.3ms
image 105/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-713-_jpg.rf.fbc9931de0a298d4f27e2470f4a89525.jpg: 640x640 6 0s, 8 2s, 34.8ms
image 106/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-720-_jpg.rf.9c8db287066e19b56b2dd809b04a380c.jpg: 640x640 1 0, 3 2s, 33.8ms
image 107/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-721-_jpg.rf.9ad085984359c2c08bfff93972b5fc5c.jpg: 640x640 5 0s, 6 2s, 35.3ms
image 108/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-736-_jpg.rf.65cab46d95e25948ff402ed47ce674f5.jpg: 640x640 3 0s, 8 2s, 33.0ms
image 109/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-775-_jpg.rf.45f87606efaffea474f4d99912e5f7b4.jpg: 640x640 1 2, 34.8ms
image 110/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-778-_jpg.rf.568c0281f600cc2bbf9deee8cfda866a.jpg: 640x640 4 0s, 5 2s, 35.1ms
image 111/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-795-_jpg.rf.de3a6aef54016b3a4616a14d1e08ea38.jpg: 640x640 8 0s, 16 2s, 34.7ms
image 112/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-835-_jpg.rf.09cdcac00b8c95c20097f5123becd4e9.jpg: 640x640 6 0s, 7 2s, 33.9ms
image 113/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-858-_jpg.rf.f4c1b37165763eea66c37e71ab8c8f40.jpg: 640x640 34.3ms
image 114/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-892-_jpg.rf.4e30fa08ea48048365a8cfc69c11b338.jpg: 640x640 1 0, 1 2, 36.9ms
image 115/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-946-_jpg.rf.82fe49cf646c495659d030549dcac09e.jpg: 640x640 1 0, 2 2s, 35.0ms
image 116/116 /content/datasets/xavi-assignment-2/test/images/image_from_china-960-_jpg.rf.624206fd8d069d806666409b83ec14b4.jpg: 640x640 2 2s, 35.2ms
Speed: 0.5ms pre-process, 35.9ms inference, 1.7ms postprocess per image at shape (1, 3, 640, 640)
Results saved to runs/detect/predict3
I am plotting some outputs to evaluate the model's performance and view examples.
image_paths = glob.glob(f'/content/runs/detect/predict3/*.jpg')
for image_path in image_paths[-3:]:
image = plt.imread(image_path)
plt.figure(figsize=(10,10))
plt.imshow(image)
plt.axis('off')
plt.show()
Now, I decided to experiment a bit and try to train a YOLOv5. To make a fair comparison between YOLOv8 and this earlier version, I will try to compare the results of this one with the previous ones using similar parameters, but not the same.
Here I am going to clone the YOLOv5 repo, intall the nedeed requirements and also at the end I will print some information regarding the enviroment.
!git clone https://github.com/ultralytics/yolov5
%cd yolov5
%pip install -qr requirements.txt
%pip install -q roboflow
import torch
import os
from IPython.display import Image, clear_output
print(f"Setup complete. Using torch {torch.__version__} ({torch.cuda.get_device_properties(0).name if torch.cuda.is_available() else 'CPU'})")
Cloning into 'yolov5'... remote: Enumerating objects: 15005, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (3/3), done. remote: Total 15005 (delta 0), reused 0 (delta 0), pack-reused 15002 Receiving objects: 100% (15005/15005), 14.09 MiB | 33.16 MiB/s, done. Resolving deltas: 100% (10285/10285), done. /content/yolov5 Setup complete. Using torch 1.13.1+cu116 (Tesla T4)
I am importing again the same dataset as used in the previous models. Eventhough the versions of the files may look different, all of them are the same.
from roboflow import Roboflow
rf = Roboflow(model_format="yolov5", notebook="ultralytics")
upload and label your dataset, and get an API KEY here: https://app.roboflow.com/?model=yolov5&ref=ultralytics
I set up here enviromen for the datasets directory, where the project will be saved.
os.environ["DATASET_DIRECTORY"] = "/content/datasets2"
rf = Roboflow(api_key="AeQawE2luCK6NpaA9hPL")
project = rf.workspace("computer-vision-f69jp").project("xavi-assignment")
dataset = project.version(2).download("yolov5")
loading Roboflow workspace... loading Roboflow project... Downloading Dataset Version Zip in /content/datasets2/xavi-assignment-2 to yolov5pytorch: 100% [167357386 / 167357386] bytes
Extracting Dataset Version Zip to /content/datasets2/xavi-assignment-2 in yolov5pytorch:: 100%|██████████| 3564/3564 [00:02<00:00, 1720.90it/s]
This code runs the training script for YOLOv5 model. The parameters selected have been:
!python train.py --img 750 --batch 16 --epochs 50 --data {dataset.location}/data.yaml --weights yolov5s.pt --cache
train: weights=yolov5s.pt, cfg=, data=/content/datasets2/xavi-assignment-2/data.yaml, hyp=data/hyps/hyp.scratch-low.yaml, epochs=50, batch_size=16, imgsz=750, rect=False, resume=False, nosave=False, noval=False, noautoanchor=False, noplots=False, evolve=None, bucket=, cache=ram, image_weights=False, device=, multi_scale=False, single_cls=False, optimizer=SGD, sync_bn=False, workers=8, project=runs/train, name=exp, exist_ok=False, quad=False, cos_lr=False, label_smoothing=0.0, patience=100, freeze=[0], save_period=-1, seed=0, local_rank=-1, entity=None, upload_dataset=False, bbox_interval=-1, artifact_alias=latest github: up to date with https://github.com/ultralytics/yolov5 ✅ YOLOv5 🚀 v7.0-72-g064365d Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) hyperparameters: lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0 ClearML: run 'pip install clearml' to automatically track, visualize and remotely train YOLOv5 🚀 in ClearML Comet: run 'pip install comet_ml' to automatically track and visualize YOLOv5 🚀 runs in Comet TensorBoard: Start with 'tensorboard --logdir runs/train', view at http://localhost:6006/ Downloading https://github.com/ultralytics/yolov5/releases/download/v7.0/yolov5s.pt to yolov5s.pt... 100% 14.1M/14.1M [00:00<00:00, 194MB/s] Overriding model.yaml nc=80 with nc=3 from n params module arguments 0 -1 1 3520 models.common.Conv [3, 32, 6, 2, 2] 1 -1 1 18560 models.common.Conv [32, 64, 3, 2] 2 -1 1 18816 models.common.C3 [64, 64, 1] 3 -1 1 73984 models.common.Conv [64, 128, 3, 2] 4 -1 2 115712 models.common.C3 [128, 128, 2] 5 -1 1 295424 models.common.Conv [128, 256, 3, 2] 6 -1 3 625152 models.common.C3 [256, 256, 3] 7 -1 1 1180672 models.common.Conv [256, 512, 3, 2] 8 -1 1 1182720 models.common.C3 [512, 512, 1] 9 -1 1 656896 models.common.SPPF [512, 512, 5] 10 -1 1 131584 models.common.Conv [512, 256, 1, 1] 11 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 12 [-1, 6] 1 0 models.common.Concat [1] 13 -1 1 361984 models.common.C3 [512, 256, 1, False] 14 -1 1 33024 models.common.Conv [256, 128, 1, 1] 15 -1 1 0 torch.nn.modules.upsampling.Upsample [None, 2, 'nearest'] 16 [-1, 4] 1 0 models.common.Concat [1] 17 -1 1 90880 models.common.C3 [256, 128, 1, False] 18 -1 1 147712 models.common.Conv [128, 128, 3, 2] 19 [-1, 14] 1 0 models.common.Concat [1] 20 -1 1 296448 models.common.C3 [256, 256, 1, False] 21 -1 1 590336 models.common.Conv [256, 256, 3, 2] 22 [-1, 10] 1 0 models.common.Concat [1] 23 -1 1 1182720 models.common.C3 [512, 512, 1, False] 24 [17, 20, 23] 1 21576 models.yolo.Detect [3, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [128, 256, 512]] Model summary: 214 layers, 7027720 parameters, 7027720 gradients, 16.0 GFLOPs Transferred 343/349 items from yolov5s.pt AMP: checks passed ✅ WARNING ⚠️ --img-size 750 must be multiple of max stride 32, updating to 768 optimizer: SGD(lr=0.01) with parameter groups 57 weight(decay=0.0), 60 weight(decay=0.0005), 60 bias albumentations: Blur(p=0.01, blur_limit=(3, 7)), MedianBlur(p=0.01, blur_limit=(3, 7)), ToGray(p=0.01), CLAHE(p=0.01, clip_limit=(1, 4.0), tile_grid_size=(8, 8)) train: Scanning /content/datasets2/xavi-assignment-2/train/labels... 1503 images, 1 backgrounds, 0 corrupt: 100% 1503/1503 [00:00<00:00, 1939.10it/s] train: New cache created: /content/datasets2/xavi-assignment-2/train/labels.cache train: Caching images (2.5GB ram): 100% 1503/1503 [00:14<00:00, 106.51it/s] val: Scanning /content/datasets2/xavi-assignment-2/valid/labels... 157 images, 0 backgrounds, 0 corrupt: 100% 157/157 [00:00<00:00, 585.60it/s] val: New cache created: /content/datasets2/xavi-assignment-2/valid/labels.cache val: Caching images (0.3GB ram): 100% 157/157 [00:01<00:00, 85.28it/s] AutoAnchor: 4.13 anchors/target, 0.994 Best Possible Recall (BPR). Current anchors are a good fit to dataset ✅ Plotting labels to runs/train/exp/labels.jpg... Image sizes 768 train, 768 val Using 2 dataloader workers Logging results to runs/train/exp Starting training for 50 epochs... Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 0/49 5.3G 0.1218 0.05822 0.04254 138 768: 0% 0/94 [00:01<?, ?it/s]WARNING ⚠️ TensorBoard graph visualization failure Sizes of tensors must match except in dimension 1. Expected size 48 but got size 47 for tensor number 1 in the list. 0/49 5.31G 0.09676 0.04875 0.02734 83 768: 100% 94/94 [00:34<00:00, 2.74it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.40it/s] all 157 811 0.817 0.171 0.14 0.0496 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 1/49 6.6G 0.07254 0.03788 0.01285 82 768: 100% 94/94 [00:33<00:00, 2.81it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.59it/s] all 157 811 0.601 0.294 0.251 0.0886 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 2/49 6.6G 0.0677 0.03425 0.008705 76 768: 100% 94/94 [00:31<00:00, 2.99it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.07it/s] all 157 811 0.639 0.347 0.299 0.127 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 3/49 6.6G 0.06043 0.033 0.007176 108 768: 100% 94/94 [00:31<00:00, 2.97it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.40it/s] all 157 811 0.707 0.355 0.359 0.162 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 4/49 6.6G 0.05424 0.03254 0.00674 87 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.02it/s] all 157 811 0.756 0.378 0.392 0.18 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 5/49 6.6G 0.05089 0.03169 0.005875 83 768: 100% 94/94 [00:32<00:00, 2.88it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.09it/s] all 157 811 0.814 0.403 0.44 0.205 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 6/49 6.6G 0.04744 0.03128 0.006062 161 768: 100% 94/94 [00:31<00:00, 3.00it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.12it/s] all 157 811 0.815 0.423 0.454 0.222 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 7/49 6.6G 0.04678 0.03099 0.005406 101 768: 100% 94/94 [00:31<00:00, 2.99it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.27it/s] all 157 811 0.855 0.405 0.447 0.237 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 8/49 6.6G 0.04502 0.03106 0.005188 116 768: 100% 94/94 [00:31<00:00, 3.00it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.01it/s] all 157 811 0.891 0.434 0.489 0.258 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 9/49 6.6G 0.04375 0.03013 0.00484 110 768: 100% 94/94 [00:31<00:00, 3.00it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.75it/s] all 157 811 0.838 0.427 0.458 0.227 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 10/49 6.6G 0.04302 0.02937 0.004954 83 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.77it/s] all 157 811 0.892 0.425 0.473 0.251 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 11/49 6.6G 0.04272 0.02963 0.004585 91 768: 100% 94/94 [00:32<00:00, 2.91it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.00it/s] all 157 811 0.872 0.437 0.475 0.246 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 12/49 6.6G 0.04155 0.02845 0.004363 122 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.35it/s] all 157 811 0.876 0.45 0.482 0.26 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 13/49 6.6G 0.04102 0.02888 0.004447 77 768: 100% 94/94 [00:30<00:00, 3.03it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.03it/s] all 157 811 0.882 0.436 0.475 0.258 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 14/49 6.6G 0.04011 0.0288 0.00422 127 768: 100% 94/94 [00:31<00:00, 3.00it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.33it/s] all 157 811 0.88 0.453 0.485 0.254 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 15/49 6.6G 0.0397 0.02716 0.004181 103 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.96it/s] all 157 811 0.884 0.434 0.471 0.262 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 16/49 6.6G 0.03804 0.02731 0.003831 112 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.06it/s] all 157 811 0.889 0.431 0.48 0.271 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 17/49 6.6G 0.03832 0.02732 0.004029 79 768: 100% 94/94 [00:31<00:00, 2.94it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.66it/s] all 157 811 0.909 0.422 0.493 0.269 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 18/49 6.6G 0.03769 0.02731 0.003905 114 768: 100% 94/94 [00:32<00:00, 2.89it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.17it/s] all 157 811 0.869 0.456 0.493 0.271 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 19/49 6.6G 0.03691 0.02737 0.003802 104 768: 100% 94/94 [00:30<00:00, 3.05it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.05it/s] all 157 811 0.891 0.45 0.503 0.281 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 20/49 6.6G 0.03638 0.02607 0.003938 81 768: 100% 94/94 [00:31<00:00, 3.00it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.92it/s] all 157 811 0.894 0.45 0.497 0.276 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 21/49 6.6G 0.03609 0.02589 0.003559 115 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.73it/s] all 157 811 0.894 0.459 0.513 0.287 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 22/49 6.6G 0.035 0.02575 0.003535 112 768: 100% 94/94 [00:31<00:00, 2.97it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.83it/s] all 157 811 0.89 0.466 0.544 0.302 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 23/49 6.6G 0.03555 0.02612 0.003521 155 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.19it/s] all 157 811 0.589 0.571 0.574 0.321 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 24/49 6.6G 0.03473 0.02519 0.003333 126 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 1.96it/s] all 157 811 0.896 0.45 0.569 0.311 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 25/49 6.6G 0.03464 0.02521 0.003285 96 768: 100% 94/94 [00:32<00:00, 2.92it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.93it/s] all 157 811 0.508 0.575 0.576 0.316 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 26/49 6.6G 0.03405 0.02497 0.003211 71 768: 100% 94/94 [00:31<00:00, 3.02it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.93it/s] all 157 811 0.906 0.457 0.532 0.298 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 27/49 6.6G 0.03392 0.02493 0.003131 138 768: 100% 94/94 [00:32<00:00, 2.93it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.89it/s] all 157 811 0.9 0.468 0.513 0.289 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 28/49 6.6G 0.03334 0.02433 0.003309 137 768: 100% 94/94 [00:30<00:00, 3.06it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.00it/s] all 157 811 0.904 0.462 0.516 0.308 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 29/49 6.6G 0.03259 0.0243 0.002945 63 768: 100% 94/94 [00:31<00:00, 2.99it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.02it/s] all 157 811 0.905 0.464 0.511 0.302 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 30/49 6.6G 0.03236 0.02455 0.003226 97 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.17it/s] all 157 811 0.904 0.46 0.516 0.305 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 31/49 6.6G 0.03132 0.02333 0.002943 101 768: 100% 94/94 [00:32<00:00, 2.92it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.02it/s] all 157 811 0.564 0.572 0.537 0.315 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 32/49 6.6G 0.03123 0.02391 0.002852 117 768: 100% 94/94 [00:32<00:00, 2.93it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.71it/s] all 157 811 0.899 0.457 0.518 0.305 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 33/49 6.6G 0.03147 0.02319 0.00278 88 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.07it/s] all 157 811 0.889 0.476 0.52 0.308 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 34/49 6.6G 0.03064 0.0235 0.002914 100 768: 100% 94/94 [00:31<00:00, 2.95it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.11it/s] all 157 811 0.903 0.463 0.52 0.309 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 35/49 6.6G 0.02995 0.02221 0.002869 103 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.96it/s] all 157 811 0.9 0.472 0.594 0.33 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 36/49 6.6G 0.0298 0.02259 0.002659 117 768: 100% 94/94 [00:32<00:00, 2.91it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.09it/s] all 157 811 0.903 0.464 0.535 0.318 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 37/49 6.6G 0.02973 0.02268 0.002745 118 768: 100% 94/94 [00:31<00:00, 2.97it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.06it/s] all 157 811 0.905 0.471 0.533 0.313 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 38/49 6.6G 0.0294 0.02223 0.002557 164 768: 100% 94/94 [00:32<00:00, 2.87it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.12it/s] all 157 811 0.565 0.581 0.536 0.316 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 39/49 6.6G 0.02881 0.02238 0.002853 129 768: 100% 94/94 [00:32<00:00, 2.91it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.49it/s] all 157 811 0.524 0.586 0.542 0.32 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 40/49 6.6G 0.029 0.02229 0.002461 100 768: 100% 94/94 [00:31<00:00, 3.01it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.07it/s] all 157 811 0.917 0.461 0.587 0.334 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 41/49 6.6G 0.02794 0.02192 0.002295 130 768: 100% 94/94 [00:32<00:00, 2.93it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.36it/s] all 157 811 0.907 0.464 0.554 0.323 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 42/49 6.6G 0.02826 0.02195 0.002484 122 768: 100% 94/94 [00:30<00:00, 3.04it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.13it/s] all 157 811 0.643 0.578 0.592 0.333 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 43/49 6.6G 0.02772 0.02119 0.00222 59 768: 100% 94/94 [00:30<00:00, 3.03it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.42it/s] all 157 811 0.618 0.585 0.596 0.337 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 44/49 6.6G 0.02782 0.0214 0.002586 100 768: 100% 94/94 [00:32<00:00, 2.87it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 2.74it/s] all 157 811 0.517 0.593 0.597 0.337 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 45/49 6.6G 0.02749 0.02155 0.002358 106 768: 100% 94/94 [00:31<00:00, 3.03it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.10it/s] all 157 811 0.91 0.471 0.552 0.327 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 46/49 6.6G 0.02699 0.0209 0.00245 125 768: 100% 94/94 [00:31<00:00, 2.98it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.25it/s] all 157 811 0.918 0.466 0.541 0.325 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 47/49 6.6G 0.02735 0.02085 0.002429 85 768: 100% 94/94 [00:30<00:00, 3.05it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.05it/s] all 157 811 0.92 0.468 0.597 0.342 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 48/49 6.6G 0.02685 0.02051 0.002287 120 768: 100% 94/94 [00:31<00:00, 3.02it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:02<00:00, 2.23it/s] all 157 811 0.922 0.464 0.597 0.343 Epoch GPU_mem box_loss obj_loss cls_loss Instances Size 49/49 6.6G 0.02681 0.02104 0.002324 135 768: 100% 94/94 [00:31<00:00, 3.02it/s] Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:01<00:00, 3.08it/s] all 157 811 0.922 0.46 0.554 0.334 50 epochs completed in 0.471 hours. Optimizer stripped from runs/train/exp/weights/last.pt, 14.5MB Optimizer stripped from runs/train/exp/weights/best.pt, 14.5MB Validating runs/train/exp/weights/best.pt... Fusing layers... Model summary: 157 layers, 7018216 parameters, 0 gradients, 15.8 GFLOPs Class Images Instances P R mAP50 mAP50-95: 100% 5/5 [00:03<00:00, 1.31it/s] all 157 811 0.921 0.464 0.597 0.343 0 157 317 0.869 0.672 0.718 0.423 1 157 4 1 0 0.246 0.0737 2 157 490 0.895 0.72 0.828 0.532 Results saved to runs/train/exp
Now, I evaluated the model on test images using the saved weights and observed the outcomes.
!python detect.py --weights runs/train/exp/weights/best.pt --img 750 --conf 0.1 --source {dataset.location}/test/images
detect: weights=['runs/train/exp/weights/best.pt'], source=/content/datasets2/xavi-assignment-2/test/images, data=data/coco128.yaml, imgsz=[750, 750], conf_thres=0.1, iou_thres=0.45, max_det=1000, device=, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs/detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False, vid_stride=1 YOLOv5 🚀 v7.0-72-g064365d Python-3.8.10 torch-1.13.1+cu116 CUDA:0 (Tesla T4, 15110MiB) Fusing layers... Model summary: 157 layers, 7018216 parameters, 0 gradients, 15.8 GFLOPs WARNING ⚠️ --img-size [750, 750] must be multiple of max stride 32, updating to [768, 768] image 1/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1006-_jpg.rf.fcffc35f7df46be0dbfbeddb60da2f37.jpg: 768x768 5 0s, 8 2s, 14.9ms image 2/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1015-_jpg.rf.b908086696208f5cb853fd9b5fe27a6e.jpg: 768x768 7 0s, 9 2s, 14.9ms image 3/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1067-_jpg.rf.0137ad485cbe02a2605d5ec05bce81df.jpg: 768x768 1 0, 1 2, 14.9ms image 4/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1088-_jpg.rf.f6c4e2dbc1c35d59b86fe8967ce2f195.jpg: 768x768 2 0s, 1 2, 14.9ms image 5/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1127-_jpg.rf.4641a82acaafceee8bd7f318ec6aa8b1.jpg: 768x768 1 0, 4 2s, 14.9ms image 6/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1133-_jpg.rf.9207e30152eb405ec982124438f626f5.jpg: 768x768 1 0, 1 2, 14.9ms image 7/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1167-_jpg.rf.5070b95b4404237515b570affa51f583.jpg: 768x768 1 2, 14.9ms image 8/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1168-1-_jpg.rf.22faca96d161f76cedadb98d701ce583.jpg: 768x768 1 2, 14.8ms image 9/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1253-_jpg.rf.d4682a68f5763cdb52916ece44dd4828.jpg: 768x768 5 0s, 7 2s, 14.8ms image 10/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1295-_jpg.rf.7f116cb966d0c2f4c1be56ba58ee671b.jpg: 768x768 1 2, 14.9ms image 11/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1296-_jpg.rf.75f9115b510bdcdffb14641e277ccba4.jpg: 768x768 3 0s, 5 2s, 14.5ms image 12/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-13-_jpg.rf.7a40e69b3e1c09658105ef710ae0826d.jpg: 768x768 1 0, 1 2, 14.3ms image 13/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1321-_jpg.rf.12597bf391179239f46403aa2d9b9a9a.jpg: 768x768 1 0, 2 2s, 14.3ms image 14/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1340-_jpg.rf.e02855b43e16dac33307501ac77bf48a.jpg: 768x768 1 2, 14.3ms image 15/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1379-_jpg.rf.7c99d9f22e29303e7d5bdfb1a70c9532.jpg: 768x768 4 2s, 14.3ms image 16/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1389-_jpg.rf.f1cd8f41f82f0e8179060c3f5db213c0.jpg: 768x768 7 0s, 7 2s, 14.3ms image 17/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1395-_jpg.rf.ef249a50b280ad5d030370fdc2408142.jpg: 768x768 2 0s, 3 2s, 14.3ms image 18/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1415-_jpg.rf.f5ed437947c24201a8a4f44bc0ad959e.jpg: 768x768 4 0s, 4 2s, 14.3ms image 19/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1416-_jpg.rf.baaef7d80c94781f3f1f8934c10a0127.jpg: 768x768 4 0s, 4 2s, 14.3ms image 20/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1426-_jpg.rf.110a561e2e43c8ed1df8e856e85de010.jpg: 768x768 3 2s, 14.3ms image 21/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1430-_jpg.rf.09aa85ab6365bcb0605cf3b0c10759c3.jpg: 768x768 12 2s, 14.3ms image 22/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1533-_jpg.rf.246f155e7e8df4d454f28d4df80bbef5.jpg: 768x768 1 0, 3 2s, 13.7ms image 23/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1600-_jpg.rf.90b634187e71aa17f2f70cb854e08b53.jpg: 768x768 3 0s, 6 2s, 13.8ms image 24/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1656-_jpg.rf.db021a1dcee28f63dcf41d8fdede94ad.jpg: 768x768 2 2s, 13.7ms image 25/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1682-_jpg.rf.9c6723e15f13beebee73ac6204c001df.jpg: 768x768 1 0, 5 2s, 13.7ms image 26/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1723-_jpg.rf.6685b5751c8cdd22d1667e44a73a19b2.jpg: 768x768 1 0, 3 2s, 13.8ms image 27/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1750-_jpg.rf.0923bb83dc226c3e240c13fff7d2dbd0.jpg: 768x768 1 2, 13.7ms image 28/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1784-_jpg.rf.f28c856c43a6f61cd19f0cf97631c240.jpg: 768x768 3 2s, 13.7ms image 29/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1810-_jpg.rf.870b52ed1a1dc7e6cf667f4c8ab666c1.jpg: 768x768 1 0, 1 2, 13.8ms image 30/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1851-_jpg.rf.c832e8a2ab32ff4fe4263cea253e4138.jpg: 768x768 1 2, 13.8ms image 31/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1852-_jpg.rf.54ced5a083d90e5da4be087facf4b1aa.jpg: 768x768 1 2, 13.8ms image 32/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1881-_jpg.rf.580a0c44abf1fcbc62db5c561a0002ce.jpg: 768x768 1 0, 3 2s, 13.8ms image 33/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1882-1-_jpg.rf.3077e4e65235deae87b49819532be160.jpg: 768x768 1 0, 4 2s, 13.0ms image 34/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1900-_jpg.rf.d1794fec7b204a55555d817fac5e8e11.jpg: 768x768 3 0s, 2 2s, 13.0ms image 35/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1966-_jpg.rf.7a1fe4524f872a830fa0f95ac3a3f7d8.jpg: 768x768 6 0s, 9 2s, 13.0ms image 36/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-1992-_jpg.rf.fffe9b7b55952ae3d443f3a273064bd3.jpg: 768x768 1 2, 13.1ms image 37/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2-_jpg.rf.6eec08d43c47f64c9ca78b000fa42dfa.jpg: 768x768 4 0s, 4 2s, 13.1ms image 38/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2070-_jpg.rf.b9d7465913077085ebfe4a80251b7de2.jpg: 768x768 1 0, 1 2, 13.1ms image 39/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2074-_jpg.rf.d8141447d731e30e1be05445ada39c6b.jpg: 768x768 6 0s, 13 2s, 13.1ms image 40/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2135-_jpg.rf.e1abc9cfa073c6b03ffef112bee801e8.jpg: 768x768 3 2s, 13.1ms image 41/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2181-_jpg.rf.a4f4d35a44dbf22578128422be93667c.jpg: 768x768 4 0s, 6 2s, 13.1ms image 42/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2187-_jpg.rf.9f3280abff1fa620b4554eadf2aafdbe.jpg: 768x768 2 0s, 2 2s, 13.0ms image 43/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2194-_jpg.rf.f3e33d572c45910e7459b56adc0d284c.jpg: 768x768 2 2s, 13.0ms image 44/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2215-_jpg.rf.c22a696e5408d5641eaab0764634daed.jpg: 768x768 3 2s, 13.1ms image 45/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2248-_jpg.rf.abd19b7897ea7ca3e236d89dfc393fca.jpg: 768x768 2 0s, 1 2, 13.0ms image 46/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-236-_jpg.rf.7cd6a2178c6d2fca3b2acca880ba82f0.jpg: 768x768 1 0, 2 2s, 13.0ms image 47/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2375-_jpg.rf.05ed09db1f9b15a2c5a891046cff3d12.jpg: 768x768 9 2s, 13.1ms image 48/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-239-_jpg.rf.eb2d756e47603865a4a4e6aa28b34cca.jpg: 768x768 1 0, 3 2s, 13.0ms image 49/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2470-_jpg.rf.2839f5cee00558b64bcc76324c9f6d93.jpg: 768x768 1 0, 4 2s, 13.1ms image 50/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2566-_jpg.rf.7ede3f2c7861e12bf1ae411eaec3f174.jpg: 768x768 11 2s, 12.8ms image 51/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2625-_jpg.rf.b2fc4099ec835b41b05b666cb63665ea.jpg: 768x768 1 0, 1 2, 12.8ms image 52/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2665-_jpg.rf.1fc2a536eb98d3fac22d30fe1d3063bc.jpg: 768x768 3 0s, 2 2s, 12.8ms image 53/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-267-_jpg.rf.5cc13828cf197606d5dc440bdca22a00.jpg: 768x768 1 2, 12.9ms image 54/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2699-_jpg.rf.44008fda1a4ad66db9d556873ecdb657.jpg: 768x768 4 0s, 2 2s, 12.8ms image 55/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2702-_jpg.rf.b82fd4e2ec2cfa4bc26651359701a80d.jpg: 768x768 2 0s, 1 2, 12.8ms image 56/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2705-_jpg.rf.352291096bacd8107fa2784859470389.jpg: 768x768 11 0s, 6 2s, 12.6ms image 57/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2739-_jpg.rf.4ef1e246b65d6ad06d81f45d17dae9af.jpg: 768x768 1 0, 2 2s, 12.6ms image 58/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2741-_jpg.rf.ec7693b1da3d215b371adb47957b3599.jpg: 768x768 4 0s, 5 2s, 12.6ms image 59/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2757-_jpg.rf.a7ffbc45fb6086122fd312ec63838fb7.jpg: 768x768 4 0s, 5 2s, 12.6ms image 60/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2826-1-_jpg.rf.5bcef3a8d8331d65ac17c905f11e390c.jpg: 768x768 5 0s, 6 2s, 12.6ms image 61/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2844-_jpg.rf.d44d6826c9f2e5accbf96abcef2dae52.jpg: 768x768 2 0s, 5 2s, 12.6ms image 62/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2845-_jpg.rf.45c8c9e5ee54a402813c5fdc79968386.jpg: 768x768 1 0, 2 2s, 12.6ms image 63/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-2869-_jpg.rf.133760bb6a054ec496b2ec19af049a53.jpg: 768x768 7 0s, 5 2s, 12.6ms image 64/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-289-_jpg.rf.2d5ff008d776144f0827bed0a8723093.jpg: 768x768 1 0, 2 2s, 12.6ms image 65/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3092-_jpg.rf.5c2fb24278a53c172170d767b31c81e2.jpg: 768x768 3 0s, 4 2s, 12.6ms image 66/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-314-_jpg.rf.6c413bee95858967ad2dc3058b2aa73b.jpg: 768x768 1 2, 12.6ms image 67/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-315-_jpg.rf.da03dea6974f80eeed598f58cbe7040e.jpg: 768x768 1 2, 14.2ms image 68/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3187-_jpg.rf.ac02dc6457bb2eae0c7fb8f63729e453.jpg: 768x768 6 2s, 13.4ms image 69/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3277-_jpg.rf.0663b24eeecc6112e4af3b78f98265b6.jpg: 768x768 3 2s, 12.7ms image 70/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3280-_jpg.rf.037927121fd603eac3a183c037f6d4fb.jpg: 768x768 6 2s, 12.7ms image 71/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3283-_jpg.rf.9412b8089be384ecde7f6f8c28ea6308.jpg: 768x768 2 2s, 12.7ms image 72/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3284-_jpg.rf.d2d3f76e155872389976506469620d91.jpg: 768x768 4 2s, 12.7ms image 73/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-341-_jpg.rf.f62a50916a5f403289e7997ae78cbd7e.jpg: 768x768 3 0s, 8 2s, 12.7ms image 74/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3647-_jpg.rf.32c6e3364f7169461c491e24d046202e.jpg: 768x768 1 0, 1 2, 12.7ms image 75/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-370-_jpg.rf.d3a543161306981edcdace41f7f25e8f.jpg: 768x768 1 0, 3 2s, 12.7ms image 76/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-3949-_jpg.rf.7099bd81480f56fc2346740f5fd85d3e.jpg: 768x768 1 2, 13.3ms image 77/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4005-_jpg.rf.ca7eb0807def03a7d4d6190eb648f3b3.jpg: 768x768 1 0, 4 2s, 12.7ms image 78/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4182-_jpg.rf.9960c353050b2099e48e4e0605b3ea9f.jpg: 768x768 7 0s, 12 2s, 13.1ms image 79/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4197-_jpg.rf.96ce536443a206bc55941a8f608b94bf.jpg: 768x768 2 0s, 2 2s, 13.7ms image 80/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4198-_jpg.rf.b25c94ceecafb6c7d917db9636beae51.jpg: 768x768 1 0, 12.7ms image 81/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4209-_jpg.rf.3488ca7a5b40781d2988758c734531d5.jpg: 768x768 1 0, 1 2, 12.7ms image 82/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4216-_jpg.rf.63a002c30068775e51b71dcff94e06cd.jpg: 768x768 2 0s, 2 2s, 12.7ms image 83/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4235-_jpg.rf.28853402ededbf01cd941595fe196e93.jpg: 768x768 7 0s, 4 1s, 5 2s, 12.7ms image 84/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4297-_jpg.rf.cdf57603a691dc34f4af618c0eb1b745.jpg: 768x768 8 0s, 8 2s, 12.7ms image 85/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4300-_jpg.rf.c11f41cbc1445944683058e3afc882ba.jpg: 768x768 3 0s, 4 2s, 12.7ms image 86/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4307-_jpg.rf.3997767077f3f3357b5d6be900e220ca.jpg: 768x768 3 0s, 3 2s, 12.7ms image 87/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4314-_jpg.rf.4f632a08488cdecd5951a01b3a9d27c5.jpg: 768x768 1 0, 1 2, 12.7ms image 88/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4319-_jpg.rf.675f9aad2a10ec3cc5966769feebe30b.jpg: 768x768 1 0, 1 2, 12.7ms image 89/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4375-_jpg.rf.b45dcff87a9934ccb30319649780f702.jpg: 768x768 9 0s, 8 1s, 8 2s, 18.5ms image 90/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4425-_jpg.rf.744cd900f3ea0addb0603078aaa0dca2.jpg: 768x768 8 0s, 7 2s, 12.7ms image 91/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4453-_jpg.rf.2f0f7c06254b5c0238febfefc4778f89.jpg: 768x768 1 0, 1 2, 12.7ms image 92/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4458-_jpg.rf.732066ae5beb1744517f988e9d6366fc.jpg: 768x768 5 0s, 8 2s, 12.7ms image 93/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4461-_jpg.rf.9fcf6607edbf161fb399ca11a3344fe8.jpg: 768x768 1 0, 1 2, 12.7ms image 94/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4482-_jpg.rf.b248d0e961cbaa016fca3d914f3556f2.jpg: 768x768 2 0s, 1 2, 12.7ms image 95/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4490-_jpg.rf.98843547c9f843d5c49a39c44a64860e.jpg: 768x768 1 2, 12.7ms image 96/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-4497-_jpg.rf.35569d8fb1eb103066c10dee5be25a32.jpg: 768x768 1 0, 1 2, 12.7ms image 97/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-486-_jpg.rf.d5e0ca24f0bd0eb498b2d9a0e3a243a0.jpg: 768x768 2 0s, 2 2s, 14.6ms image 98/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-487-_jpg.rf.ddfe445fccb84291b520ef0d8aa79037.jpg: 768x768 2 0s, 2 2s, 14.6ms image 99/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-629-_jpg.rf.6e9085bd517b5bb4522a70b4d0a44e77.jpg: 768x768 5 0s, 3 2s, 14.6ms image 100/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-674-_jpg.rf.54acbedf14c5233e7e9de14d9f3a0b1a.jpg: 768x768 9 0s, 18 2s, 14.6ms image 101/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-688-_jpg.rf.1f8e4088f3dc382d92321fb8e0099052.jpg: 768x768 13 0s, 14 2s, 14.9ms image 102/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-689-_jpg.rf.78f30433dda124f0389ac5f21ba9d232.jpg: 768x768 15 0s, 14 2s, 14.9ms image 103/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-693-_jpg.rf.4e77574ef0da13c3b0f8457ba3374e4c.jpg: 768x768 10 0s, 10 2s, 14.9ms image 104/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-710-_jpg.rf.2592a5747f008c6c21d77c8d99fa5ca2.jpg: 768x768 1 0, 3 2s, 15.0ms image 105/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-713-_jpg.rf.fbc9931de0a298d4f27e2470f4a89525.jpg: 768x768 8 0s, 11 2s, 14.9ms image 106/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-720-_jpg.rf.9c8db287066e19b56b2dd809b04a380c.jpg: 768x768 2 0s, 7 2s, 14.9ms image 107/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-721-_jpg.rf.9ad085984359c2c08bfff93972b5fc5c.jpg: 768x768 5 0s, 7 2s, 14.9ms image 108/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-736-_jpg.rf.65cab46d95e25948ff402ed47ce674f5.jpg: 768x768 12 0s, 12 2s, 15.0ms image 109/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-775-_jpg.rf.45f87606efaffea474f4d99912e5f7b4.jpg: 768x768 2 0s, 2 2s, 18.9ms image 110/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-778-_jpg.rf.568c0281f600cc2bbf9deee8cfda866a.jpg: 768x768 3 0s, 4 2s, 14.9ms image 111/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-795-_jpg.rf.de3a6aef54016b3a4616a14d1e08ea38.jpg: 768x768 18 0s, 20 2s, 14.9ms image 112/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-835-_jpg.rf.09cdcac00b8c95c20097f5123becd4e9.jpg: 768x768 6 0s, 5 2s, 15.1ms image 113/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-858-_jpg.rf.f4c1b37165763eea66c37e71ab8c8f40.jpg: 768x768 (no detections), 17.0ms image 114/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-892-_jpg.rf.4e30fa08ea48048365a8cfc69c11b338.jpg: 768x768 1 0, 1 2, 14.9ms image 115/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-946-_jpg.rf.82fe49cf646c495659d030549dcac09e.jpg: 768x768 1 0, 2 2s, 14.9ms image 116/116 /content/datasets2/xavi-assignment-2/test/images/image_from_china-960-_jpg.rf.624206fd8d069d806666409b83ec14b4.jpg: 768x768 2 0s, 6 2s, 14.9ms Speed: 0.6ms pre-process, 13.7ms inference, 1.2ms NMS per image at shape (1, 3, 768, 768) Results saved to runs/detect/exp
Image(filename='/content/yolov5/runs/train/exp/results.png', width=1000)
Image(filename='/content/yolov5/runs/train/exp/val_batch0_labels.jpg', width=900)
The study was conducted to evaluate the performance of four different computer vision models for object detection in the PIKTOR dataset. The models were YOLOv8s.pt, YOLOv8m.pt, YOLOv8l.pt, and YOLOv5, with the task being to predict the classes of Hat, Vest, and Worker with the highest Mean Average Precision (MAP) and accuracy possible. The idea was to evaluate which one of the three different YOLOv8 models was performing the best using the same hyperparameters. Some hyperparameters had been applied and modified many times to find a combination that gets the best possible relationship between score and computational time. After that hyperparameters tunning, some of them have been stablished.
The dataset has been created by using Roboflow. The images were uploaded and labeled there, and were pre-processed by flipping them horizontally and vertically, and cropping with 0% Minimum Zoom and 20% Maximum Zoom. This dataset is a bit unbalanced on Vest class, that have led to overfitting and high errors in some cases (I tried to solve that using drop out but at the end the MAP in that class was not right).
In YOLOv8 models, I decided to use some hyperparameters that compromise a bit the computational time of the model, so I priorized experimenting with hyperparameters than increasing epochs. That’s why for all of them the epochs had been 30, even though that graphically we can understand that larger epochs could give better results (both in classification and object detection tasks). In these loss function/MAP graphs we can appreciate a clear decreased tendency that do not end, so increasing epochs would be a future step with more computational resources. Regarding YOLOv5, I used 50 epochs but I experimented a bit less with its hyperparameters. In the case of YOLOv5 graphs, we can see how that curve tends to stop decreasing, so 50 epochs would be good enough.
The results showed that YOLOv8 emerged as the best model compared to YOLOv5, with the YOLOv8 models showing the highest MAP in detecting the objects of interest. The superior performance of YOLOv8 can be attributed to the advancements in its architecture and optimization techniques that have been implemented, leading to improved performance compared to its predecessors. In the training phase, the YOLOv8m.pt model performed the best overall, but YOLOv8s.pt and YOLOv8l.pt had similar MAP and were better at detecting the Vest class.
Overall, the YOLOv8m.pt model was found to be the most suitable for object detection in the PIKTOR dataset, with the highest MAP in identifying Hat, Vest, and Worker classes. This highlights the potential of using advanced computer vision models for real-world applications. It is important to note that the results of this study are specific to the PIKTOR dataset and the pre-processing techniques used and for the hyperparameters selected in this project, so it may not be enough to generalize to other datasets or tasks.